@@ -859,8 +859,7 @@ func LinkAccountPostRegister(ctx *context.Context, cpt *captcha.Captcha, form au
859859 ctx .Redirect (setting .AppSubURL + "/user/login" )
860860}
861861
862- // SignOut sign out from login status
863- func SignOut (ctx * context.Context ) {
862+ func handleSignOut (ctx * context.Context ) {
864863 ctx .Session .Delete ("uid" )
865864 ctx .Session .Delete ("uname" )
866865 ctx .Session .Delete ("socialId" )
@@ -870,6 +869,11 @@ func SignOut(ctx *context.Context) {
870869 ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true )
871870 ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , "" , setting .SessionConfig .Secure , true )
872871 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 )
873877 ctx .Redirect (setting .AppSubURL + "/" )
874878}
875879
@@ -1139,6 +1143,8 @@ func ForgotPasswdPost(ctx *context.Context) {
11391143func ResetPasswd (ctx * context.Context ) {
11401144 ctx .Data ["Title" ] = ctx .Tr ("auth.reset_password" )
11411145
1146+ // TODO for security and convenience, show the username / email here
1147+
11421148 code := ctx .Query ("code" )
11431149 if len (code ) == 0 {
11441150 ctx .Error (404 )
@@ -1179,6 +1185,10 @@ func ResetPasswdPost(ctx *context.Context) {
11791185 ctx .ServerError ("UpdateUser" , err )
11801186 return
11811187 }
1188+
1189+ // Just in case the user is signed in to another account
1190+ handleSignOut (ctx )
1191+
11821192 u .HashPassword (passwd )
11831193 u .MustChangePassword = false
11841194 if err := models .UpdateUserCols (u , "must_change_password" , "passwd" , "rands" , "salt" ); err != nil {
@@ -1187,6 +1197,9 @@ func ResetPasswdPost(ctx *context.Context) {
11871197 }
11881198
11891199 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
11901203 ctx .Redirect (setting .AppSubURL + "/user/login" )
11911204 return
11921205 }
0 commit comments