diff options
Diffstat (limited to 'captain')
-rw-r--r-- | captain/gemini.f90 | 6 | ||||
-rw-r--r-- | captain/response.f90 | 24 |
2 files changed, 24 insertions, 6 deletions
diff --git a/captain/gemini.f90 b/captain/gemini.f90 index b14078d..cb829e8 100644 --- a/captain/gemini.f90 +++ b/captain/gemini.f90 @@ -237,6 +237,8 @@ contains character(1024)::text_request character(UUID_LENGTH+8)::first + + character(len=:), pointer::gemlink integer::rendered_unit, ioerror @@ -350,6 +352,10 @@ contains call write_input_request(ssl, resp%message, code=resp%code) case(GEMINI_CODE_REDIRECT) + if(req%is_authenticated_user()) then + gemlink => gemini_session_link_url(resp%url, req%token) + call resp%set_url(gemlink) + end if call write_redirect(ssl, resp%url) case(GEMINI_CODE_PERMFAIL) diff --git a/captain/response.f90 b/captain/response.f90 index 49f735e..6d9bf46 100644 --- a/captain/response.f90 +++ b/captain/response.f90 @@ -161,8 +161,13 @@ contains if(link(1:1) == "/") then if(present(session_token)) then if(associated(session_token)) then - nl = nl + 9 + len_trim(session_token) - prepend_session = .true. + + ! Make sure the url doesn't already have a session token... + if(index(link, "/session-"//trim(session_token)) /= 1) then + nl = nl + 9 + len_trim(session_token) + prepend_session = .true. + end if + end if end if end if @@ -736,11 +741,18 @@ contains implicit none class(response)::resp - character(*), intent(in)::str + character(*), intent(in), optional::str - if(len_trim(str) > 0) then - allocate(character(len=len_trim(str)) :: resp%url) - resp%url = trim(str) + if(associated(resp%url)) then + deallocate(resp%url) + resp%url => null() + end if + + if(present(str)) then + if(len_trim(str) > 0) then + allocate(character(len=len_trim(str)) :: resp%url) + resp%url = trim(str) + end if end if end subroutine response_set_url |