@@ -859,8 +859,7 @@ func LinkAccountPostRegister(ctx *context.Context, cpt *captcha.Captcha, form au
859
859
ctx .Redirect (setting .AppSubURL + "/user/login" )
860
860
}
861
861
862
- // SignOut sign out from login status
863
- func SignOut (ctx * context.Context ) {
862
+ func handleSignOut (ctx * context.Context ) {
864
863
ctx .Session .Delete ("uid" )
865
864
ctx .Session .Delete ("uname" )
866
865
ctx .Session .Delete ("socialId" )
@@ -870,6 +869,11 @@ func SignOut(ctx *context.Context) {
870
869
ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true )
871
870
ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true )
872
871
ctx .SetCookie ("lang" , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true ) // Setting the lang cookie will trigger the middleware to reset the language ot previous state.
872
+ }
873
+
874
+ // SignOut sign out from login status
875
+ func SignOut (ctx * context.Context ) {
876
+ handleSignOut (ctx )
873
877
ctx .Redirect (setting .AppSubURL + "/" )
874
878
}
875
879
@@ -1139,6 +1143,8 @@ func ForgotPasswdPost(ctx *context.Context) {
1139
1143
func ResetPasswd (ctx * context.Context ) {
1140
1144
ctx .Data ["Title" ] = ctx .Tr ("auth.reset_password" )
1141
1145
1146
+ // TODO for security and convenience, show the username / email here
1147
+
1142
1148
code := ctx .Query ("code" )
1143
1149
if len (code ) == 0 {
1144
1150
ctx .Error (404 )
@@ -1179,6 +1185,10 @@ func ResetPasswdPost(ctx *context.Context) {
1179
1185
ctx .ServerError ("UpdateUser" , err )
1180
1186
return
1181
1187
}
1188
+
1189
+ // Just in case the user is signed in to another account
1190
+ handleSignOut (ctx )
1191
+
1182
1192
u .HashPassword (passwd )
1183
1193
u .MustChangePassword = false
1184
1194
if err := models .UpdateUserCols (u , "must_change_password" , "passwd" , "rands" , "salt" ); err != nil {
@@ -1187,6 +1197,9 @@ func ResetPasswdPost(ctx *context.Context) {
1187
1197
}
1188
1198
1189
1199
log .Trace ("User password reset: %s" , u .Name )
1200
+
1201
+ // TODO change the former form to have password retype and remember me,
1202
+ // then sign in here instead of redirecting
1190
1203
ctx .Redirect (setting .AppSubURL + "/user/login" )
1191
1204
return
1192
1205
}
0 commit comments