@@ -65,8 +65,8 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
65
65
defer func () {
66
66
if ! isSucceed {
67
67
log .Trace ("auto-login cookie cleared: %s" , uname )
68
- ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
69
- ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
68
+ ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
69
+ ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
70
70
}
71
71
}()
72
72
@@ -96,7 +96,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
96
96
return false , err
97
97
}
98
98
99
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
99
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
100
100
return true , nil
101
101
}
102
102
@@ -110,13 +110,13 @@ func checkAutoLogin(ctx *context.Context) bool {
110
110
111
111
redirectTo := ctx .Query ("redirect_to" )
112
112
if len (redirectTo ) > 0 {
113
- ctx .SetCookie ("redirect_to" , redirectTo , 0 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
113
+ ctx .SetCookie ("redirect_to" , redirectTo , 0 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
114
114
} else {
115
115
redirectTo = ctx .GetCookie ("redirect_to" )
116
116
}
117
117
118
118
if isSucceed {
119
- ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
119
+ ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
120
120
ctx .RedirectToFirst (redirectTo , setting .AppSubURL + string (setting .LandingPageURL ))
121
121
return true
122
122
}
@@ -498,9 +498,9 @@ func handleSignIn(ctx *context.Context, u *models.User, remember bool) {
498
498
func handleSignInFull (ctx * context.Context , u * models.User , remember bool , obeyRedirect bool ) string {
499
499
if remember {
500
500
days := 86400 * setting .LogInRememberDays
501
- ctx .SetCookie (setting .CookieUserName , u .Name , days , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
501
+ ctx .SetCookie (setting .CookieUserName , u .Name , days , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
502
502
ctx .SetSuperSecureCookie (base .EncodeMD5 (u .Rands + u .Passwd ),
503
- setting .CookieRememberName , u .Name , days , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
503
+ setting .CookieRememberName , u .Name , days , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
504
504
}
505
505
506
506
_ = ctx .Session .Delete ("openid_verified_uri" )
@@ -531,10 +531,10 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
531
531
}
532
532
}
533
533
534
- ctx .SetCookie ("lang" , u .Language , nil , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
534
+ ctx .SetCookie ("lang" , u .Language , nil , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
535
535
536
536
// Clear whatever CSRF has right now, force to generate a new one
537
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
537
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
538
538
539
539
// Register last login
540
540
u .SetLastLogin ()
@@ -544,7 +544,7 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
544
544
}
545
545
546
546
if redirectTo := ctx .GetCookie ("redirect_to" ); len (redirectTo ) > 0 && ! utils .IsExternalURL (redirectTo ) {
547
- ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
547
+ ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
548
548
if obeyRedirect {
549
549
ctx .RedirectToFirst (redirectTo )
550
550
}
@@ -650,7 +650,7 @@ func handleOAuth2SignIn(u *models.User, gothUser goth.User, ctx *context.Context
650
650
}
651
651
652
652
// Clear whatever CSRF has right now, force to generate a new one
653
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
653
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
654
654
655
655
// Register last login
656
656
u .SetLastLogin ()
@@ -665,7 +665,7 @@ func handleOAuth2SignIn(u *models.User, gothUser goth.User, ctx *context.Context
665
665
}
666
666
667
667
if redirectTo := ctx .GetCookie ("redirect_to" ); len (redirectTo ) > 0 {
668
- ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
668
+ ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
669
669
ctx .RedirectToFirst (redirectTo )
670
670
return
671
671
}
@@ -1043,11 +1043,11 @@ func LinkAccountPostRegister(ctx *context.Context) {
1043
1043
func HandleSignOut (ctx * context.Context ) {
1044
1044
_ = ctx .Session .Flush ()
1045
1045
_ = ctx .Session .Destroy (ctx .Resp , ctx .Req )
1046
- ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
1047
- ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
1048
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite ))
1049
- ctx .SetCookie ("lang" , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSiteString (setting .SessionConfig .SameSite )) // Setting the lang cookie will trigger the middleware to reset the language ot previous state.
1050
- ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL ) // logout default should set redirect to to default
1046
+ ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
1047
+ ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
1048
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite ))
1049
+ ctx .SetCookie ("lang" , "" , - 1 , setting .AppSubURL , setting .SessionConfig .Domain , setting .SessionConfig .Secure , true , middleware .SameSite (setting .SessionConfig .SameSite )) // Setting the lang cookie will trigger the middleware to reset the language ot previous state.
1050
+ ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL ) // logout default should set redirect to to default
1051
1051
}
1052
1052
1053
1053
// SignOut sign out from login status
0 commit comments