Skip to content

Commit 6f5656a

Browse files
authored
Logout POST action (#10582) (#10585)
* Change logout to POST * Update for redirect * Revert octicon to font Signed-off-by: jolheiser <[email protected]>
1 parent e4a876c commit 6f5656a

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

integrations/signout_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestSignOut(t *testing.T) {
1414

1515
session := loginUser(t, "user2")
1616

17-
req := NewRequest(t, "GET", "/user/logout")
17+
req := NewRequest(t, "POST", "/user/logout")
1818
session.MakeRequest(t, req, http.StatusFound)
1919

2020
// try to view a private repo, should fail

routers/routes/routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ func RegisterRoutes(m *macaron.Macaron) {
399399
m.Post("/recover_account", user.ResetPasswdPost)
400400
m.Get("/forgot_password", user.ForgotPasswd)
401401
m.Post("/forgot_password", user.ForgotPasswdPost)
402-
m.Get("/logout", user.SignOut)
402+
m.Post("/logout", user.SignOut)
403403
})
404404
// ***** END: User *****
405405

templates/base/head_navbar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
{{end}}
110110

111111
<div class="divider"></div>
112-
<a class="item" href="{{AppSubUrl}}/user/logout">
112+
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout" data-redirect="{{AppSubUrl}}/">
113113
<i class="octicon octicon-sign-out"></i>
114114
{{.i18n.Tr "sign_out"}}<!-- Sign Out -->
115115
</a>

web_src/js/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,11 +2740,14 @@ function showAddAllPopup() {
27402740

27412741
function linkAction() {
27422742
const $this = $(this);
2743+
const redirect = $this.data('redirect');
27432744
$.post($this.data('url'), {
27442745
_csrf: csrf
27452746
}).done((data) => {
27462747
if (data.redirect) {
27472748
window.location.href = data.redirect;
2749+
} else if (redirect) {
2750+
window.location.href = redirect;
27482751
} else {
27492752
window.location.reload();
27502753
}

0 commit comments

Comments
 (0)