summaryrefslogtreecommitdiffstats
path: root/modules/context/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 /modules/context/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 'modules/context/auth.go')
-rw-r--r--modules/context/auth.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/context/auth.go b/modules/context/auth.go
index 7cc29debbd..5e071b4fab 100644
--- a/modules/context/auth.go
+++ b/modules/context/auth.go
@@ -67,7 +67,7 @@ func Toggle(options *ToggleOptions) func(ctx *Context) {
}
if !options.SignOutRequired && !options.DisableCSRF && ctx.Req.Method == "POST" {
- ctx.csrf.Validate(ctx)
+ ctx.Csrf.Validate(ctx)
if ctx.Written() {
return
}
@@ -89,7 +89,7 @@ func Toggle(options *ToggleOptions) func(ctx *Context) {
// Redirect to log in page if auto-signin info is provided and has not signed in.
if !options.SignOutRequired && !ctx.IsSigned &&
- len(ctx.GetCookie(setting.CookieUserName)) > 0 {
+ len(ctx.GetSiteCookie(setting.CookieUserName)) > 0 {
if ctx.Req.URL.Path != "/user/events" {
middleware.SetRedirectToCookie(ctx.Resp, setting.AppSubURL+ctx.Req.URL.RequestURI())
}