From 215a35640cee5e1ffd4d48333283caf083ead85c Mon Sep 17 00:00:00 2001 From: Hunter Miller Date: Mon, 24 Apr 2023 15:50:11 -0500 Subject: [PATCH 1/2] eyre: if logged in and accessing login page, redirect --- pkg/arvo/sys/vane/eyre.hoon | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index 87cbe4d867..ac53537ec4 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -986,14 +986,37 @@ |= [secure=? =address =request:http] ^- [(list move) server-state] :: - :: if we received a simple get, just return the page + :: if we received a simple get, redirect if logged in otherwise + :: show login page :: ?: =('GET' method.request) :: parse the arguments out of request uri :: =+ request-line=(parse-request-line url.request) - %^ return-static-data-on-duct 200 'text/html' - (login-page (get-header:http 'redirect' args.request-line) our %.n) + =/ redirect (get-header:http 'redirect' args.request-line) + ?. (request-is-logged-in request) + %^ return-static-data-on-duct 200 'text/html' + (login-page redirect our %.n) + =/ session-id (session-id-from-request request) + :: session-id should always be populated here since we are logged in + ?~ session-id + %^ return-static-data-on-duct 200 'text/html' + (login-page redirect our %.n) + =/ cookie-line=@t + (session-cookie-string u.session-id &) + =/ actual-redirect + ?~ redirect '/' + ?:(=(u.redirect '') '/' u.redirect) + %- handle-response + :* %start + :- status-code=303 + ^= headers + :~ ['location' actual-redirect] + ['set-cookie' cookie-line] + == + data=~ + complete=%.y + == :: if we are not a post, return an error :: ?. =('POST' method.request) From 06af50a9b9258605b2a9db2f7d1673c6360987d4 Mon Sep 17 00:00:00 2001 From: Hunter Miller Date: Mon, 24 Apr 2023 15:52:56 -0500 Subject: [PATCH 2/2] eyre: fixing errant whitespace --- pkg/arvo/sys/vane/eyre.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index ac53537ec4..b5e6e56c53 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -986,7 +986,7 @@ |= [secure=? =address =request:http] ^- [(list move) server-state] :: - :: if we received a simple get, redirect if logged in otherwise + :: if we received a simple get, redirect if logged in otherwise :: show login page :: ?: =('GET' method.request)