Skip to content

Commit

Permalink
Make logout go to the origin page
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbkr committed Nov 7, 2023
1 parent 29a4d77 commit 9851ff6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 8 additions & 4 deletions lib/Routes.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ sub routes(CITestSetManager $tsm, SourceArchiveCreator $sac, GitHubInterface $gi
}

sub gen-login-data($origin) {
my $url-data = $github-interface.oauth-step-one-url(encode-percents($origin));
return $url-data;
return {
login-url => $github-interface.oauth-step-one-url(encode-percents($origin)),
:$origin,
}
}

post -> "logout" {
set-cookie $jwt-gh-cookie-name, "", Max-Age => 0;
redirect :see-other, "/";
request-body -> (:$origin!) {
set-cookie $jwt-gh-cookie-name, "", Max-Age => 0;
redirect :see-other, $origin;
}
}

get -> "gh-oauth-callback", :$code, :$state {
Expand Down
5 changes: 3 additions & 2 deletions resources/templates/login.crotmp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
<?$logged-in>
<span class="username"><$name></span>
<form action="<$logout-url>" method="post">
<input type="hidden" name="origin" value="<$login-data.origin>">
<input type="submit" value="Logout">
</form>
</?>
<!>
<form action="<$login-data.url>" method="get">
<@$login-data.query-params>
<form action="<$login-data.login-url.url>" method="get">
<@$login-data.login-url.query-params>
<input type="hidden" name="<.key>" value="<.value>">
</@>
<input type="submit" value="Login">
Expand Down

0 comments on commit 9851ff6

Please sign in to comment.