summaryrefslogtreecommitdiffstats
path: root/services/auth/auth.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-04-14 03:45:33 +0800
committerGitHub <noreply@github.com>2023-04-13 15:45:33 -0400
commit5b9557aef59b190c55de9ea218bf51152bc04786 (patch)
treed77004c983875886a00acd1561a74b8c3d5ce682 /services/auth/auth.go
parentb7221bec34fd49495234a18c26e4f5d81483e102 (diff)
downloadgitea-5b9557aef59b190c55de9ea218bf51152bc04786.tar.gz
gitea-5b9557aef59b190c55de9ea218bf51152bc04786.zip
Refactor cookie (#24107)
Close #24062 At the beginning, I just wanted to fix the warning mentioned by #24062 But, the cookie code really doesn't look good to me, so clean up them. Complete the TODO on `SetCookie`: > TODO: Copied from gitea.com/macaron/macaron and should be improved after macaron removed.
Diffstat (limited to 'services/auth/auth.go')
-rw-r--r--services/auth/auth.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/services/auth/auth.go b/services/auth/auth.go
index 00e277c41a..905c776e58 100644
--- a/services/auth/auth.go
+++ b/services/auth/auth.go
@@ -13,6 +13,7 @@ import (
"code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/auth/webauthn"
+ gitea_context "code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/session"
"code.gitea.io/gitea/modules/setting"
@@ -91,5 +92,7 @@ func handleSignIn(resp http.ResponseWriter, req *http.Request, sess SessionStore
middleware.SetLocaleCookie(resp, user.Language, 0)
// Clear whatever CSRF has right now, force to generate a new one
- middleware.DeleteCSRFCookie(resp)
+ if ctx := gitea_context.GetContext(req); ctx != nil {
+ ctx.Csrf.DeleteCookie(ctx)
+ }
}