mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Logout POST action (#10582)
* Change logout to POST * Update for redirect Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
		@@ -14,7 +14,7 @@ func TestSignOut(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	session := loginUser(t, "user2")
 | 
			
		||||
 | 
			
		||||
	req := NewRequest(t, "GET", "/user/logout")
 | 
			
		||||
	req := NewRequest(t, "POST", "/user/logout")
 | 
			
		||||
	session.MakeRequest(t, req, http.StatusFound)
 | 
			
		||||
 | 
			
		||||
	// try to view a private repo, should fail
 | 
			
		||||
 
 | 
			
		||||
@@ -413,7 +413,7 @@ func RegisterRoutes(m *macaron.Macaron) {
 | 
			
		||||
		m.Post("/recover_account", user.ResetPasswdPost)
 | 
			
		||||
		m.Get("/forgot_password", user.ForgotPasswd)
 | 
			
		||||
		m.Post("/forgot_password", user.ForgotPasswdPost)
 | 
			
		||||
		m.Get("/logout", user.SignOut)
 | 
			
		||||
		m.Post("/logout", user.SignOut)
 | 
			
		||||
	})
 | 
			
		||||
	// ***** END: User *****
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -115,7 +115,7 @@
 | 
			
		||||
					{{end}}
 | 
			
		||||
 | 
			
		||||
					<div class="divider"></div>
 | 
			
		||||
					<a class="item" href="{{AppSubUrl}}/user/logout">
 | 
			
		||||
					<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout" data-redirect="{{AppSubUrl}}/">
 | 
			
		||||
						{{svg "octicon-sign-out" 16}}
 | 
			
		||||
						{{.i18n.Tr "sign_out"}}<!-- Sign Out -->
 | 
			
		||||
					</a>
 | 
			
		||||
 
 | 
			
		||||
@@ -2741,11 +2741,14 @@ function showAddAllPopup() {
 | 
			
		||||
 | 
			
		||||
function linkAction() {
 | 
			
		||||
  const $this = $(this);
 | 
			
		||||
  const redirect = $this.data('redirect');
 | 
			
		||||
  $.post($this.data('url'), {
 | 
			
		||||
    _csrf: csrf
 | 
			
		||||
  }).done((data) => {
 | 
			
		||||
    if (data.redirect) {
 | 
			
		||||
      window.location.href = data.redirect;
 | 
			
		||||
    } else if (redirect) {
 | 
			
		||||
      window.location.href = redirect;
 | 
			
		||||
    } else {
 | 
			
		||||
      window.location.reload();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user