Skip to content

Commit ddf96f6

Browse files
authored
Use JSON response for "user/logout" (#25522)
The request sent to "user/logout" is from "link-action", it expects to get JSON response.
1 parent da6df0d commit ddf96f6

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

routers/web/auth/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func SignOut(ctx *context.Context) {
383383
})
384384
}
385385
HandleSignOut(ctx)
386-
ctx.Redirect(setting.AppSubURL + "/")
386+
ctx.JSONRedirect(setting.AppSubURL + "/")
387387
}
388388

389389
// SignUp render the register page

templates/base/head_navbar.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</div>
6969

7070
<div class="divider"></div>
71-
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout" data-redirect="{{AppSubUrl}}/">
71+
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout">
7272
{{svg "octicon-sign-out"}}
7373
{{.locale.Tr "sign_out"}}
7474
</a>
@@ -186,7 +186,7 @@
186186
{{end}}
187187

188188
<div class="divider"></div>
189-
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout" data-redirect="{{AppSubUrl}}/">
189+
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout">
190190
{{svg "octicon-sign-out"}}
191191
{{.locale.Tr "sign_out"}}
192192
</a>

tests/integration/signout_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestSignOut(t *testing.T) {
1616
session := loginUser(t, "user2")
1717

1818
req := NewRequest(t, "POST", "/user/logout")
19-
session.MakeRequest(t, req, http.StatusSeeOther)
19+
session.MakeRequest(t, req, http.StatusOK)
2020

2121
// try to view a private repo, should fail
2222
req = NewRequest(t, "GET", "/user2/repo2")

0 commit comments

Comments
 (0)