Skip to content

Commit 0e2217b

Browse files
authored
Logout POST action (#10582)
* Change logout to POST * Update for redirect Signed-off-by: jolheiser <[email protected]>
1 parent bea497f commit 0e2217b

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
@@ -413,7 +413,7 @@ func RegisterRoutes(m *macaron.Macaron) {
413413
m.Post("/recover_account", user.ResetPasswdPost)
414414
m.Get("/forgot_password", user.ForgotPasswd)
415415
m.Post("/forgot_password", user.ForgotPasswdPost)
416-
m.Get("/logout", user.SignOut)
416+
m.Post("/logout", user.SignOut)
417417
})
418418
// ***** END: User *****
419419

templates/base/head_navbar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
{{end}}
116116

117117
<div class="divider"></div>
118-
<a class="item" href="{{AppSubUrl}}/user/logout">
118+
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout" data-redirect="{{AppSubUrl}}/">
119119
{{svg "octicon-sign-out" 16}}
120120
{{.i18n.Tr "sign_out"}}<!-- Sign Out -->
121121
</a>

web_src/js/index.js

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

27422742
function linkAction() {
27432743
const $this = $(this);
2744+
const redirect = $this.data('redirect');
27442745
$.post($this.data('url'), {
27452746
_csrf: csrf
27462747
}).done((data) => {
27472748
if (data.redirect) {
27482749
window.location.href = data.redirect;
2750+
} else if (redirect) {
2751+
window.location.href = redirect;
27492752
} else {
27502753
window.location.reload();
27512754
}

0 commit comments

Comments
 (0)