|
|
|
@ -44,8 +44,8 @@ func AutoSignIn(ctx *context.Context) (bool, error) { |
|
|
|
|
defer func() { |
|
|
|
|
if !isSucceed { |
|
|
|
|
log.Trace("auto-login cookie cleared: %s", uname) |
|
|
|
|
ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl) |
|
|
|
|
ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl) |
|
|
|
|
ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubURL) |
|
|
|
|
ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubURL) |
|
|
|
|
} |
|
|
|
|
}() |
|
|
|
|
|
|
|
|
@ -65,7 +65,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) { |
|
|
|
|
isSucceed = true |
|
|
|
|
ctx.Session.Set("uid", u.ID) |
|
|
|
|
ctx.Session.Set("uname", u.Name) |
|
|
|
|
ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl) |
|
|
|
|
ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubURL) |
|
|
|
|
return true, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -82,17 +82,17 @@ func SignIn(ctx *context.Context) { |
|
|
|
|
|
|
|
|
|
redirectTo := ctx.Query("redirect_to") |
|
|
|
|
if len(redirectTo) > 0 { |
|
|
|
|
ctx.SetCookie("redirect_to", redirectTo, 0, setting.AppSubUrl) |
|
|
|
|
ctx.SetCookie("redirect_to", redirectTo, 0, setting.AppSubURL) |
|
|
|
|
} else { |
|
|
|
|
redirectTo, _ = url.QueryUnescape(ctx.GetCookie("redirect_to")) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if isSucceed { |
|
|
|
|
if len(redirectTo) > 0 { |
|
|
|
|
ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl) |
|
|
|
|
ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL) |
|
|
|
|
ctx.Redirect(redirectTo) |
|
|
|
|
} else { |
|
|
|
|
ctx.Redirect(setting.AppSubUrl + "/") |
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/") |
|
|
|
|
} |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -121,16 +121,16 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) { |
|
|
|
|
|
|
|
|
|
if form.Remember { |
|
|
|
|
days := 86400 * setting.LogInRememberDays |
|
|
|
|
ctx.SetCookie(setting.CookieUserName, u.Name, days, setting.AppSubUrl) |
|
|
|
|
ctx.SetCookie(setting.CookieUserName, u.Name, days, setting.AppSubURL) |
|
|
|
|
ctx.SetSuperSecureCookie(base.EncodeMD5(u.Rands+u.Passwd), |
|
|
|
|
setting.CookieRememberName, u.Name, days, setting.AppSubUrl) |
|
|
|
|
setting.CookieRememberName, u.Name, days, setting.AppSubURL) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ctx.Session.Set("uid", u.ID) |
|
|
|
|
ctx.Session.Set("uname", u.Name) |
|
|
|
|
|
|
|
|
|
// Clear whatever CSRF has right now, force to generate a new one
|
|
|
|
|
ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl) |
|
|
|
|
ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubURL) |
|
|
|
|
|
|
|
|
|
// Register last login
|
|
|
|
|
u.SetLastLogin() |
|
|
|
@ -140,12 +140,12 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 { |
|
|
|
|
ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl) |
|
|
|
|
ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL) |
|
|
|
|
ctx.Redirect(redirectTo) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubUrl + "/") |
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SignOut sign out from login status
|
|
|
|
@ -155,10 +155,10 @@ func SignOut(ctx *context.Context) { |
|
|
|
|
ctx.Session.Delete("socialId") |
|
|
|
|
ctx.Session.Delete("socialName") |
|
|
|
|
ctx.Session.Delete("socialEmail") |
|
|
|
|
ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl) |
|
|
|
|
ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl) |
|
|
|
|
ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl) |
|
|
|
|
ctx.Redirect(setting.AppSubUrl + "/") |
|
|
|
|
ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubURL) |
|
|
|
|
ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubURL) |
|
|
|
|
ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubURL) |
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SignUp render the register page
|
|
|
|
@ -255,7 +255,7 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubUrl + "/user/login") |
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/user/login") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Activate render activate user page
|
|
|
|
@ -303,7 +303,7 @@ func Activate(ctx *context.Context) { |
|
|
|
|
|
|
|
|
|
ctx.Session.Set("uid", user.ID) |
|
|
|
|
ctx.Session.Set("uname", user.Name) |
|
|
|
|
ctx.Redirect(setting.AppSubUrl + "/") |
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -326,7 +326,7 @@ func ActivateEmail(ctx *context.Context) { |
|
|
|
|
ctx.Flash.Success(ctx.Tr("settings.add_email_success")) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubUrl + "/user/settings/email") |
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/user/settings/email") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -437,7 +437,7 @@ func ResetPasswdPost(ctx *context.Context) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.Trace("User password reset: %s", u.Name) |
|
|
|
|
ctx.Redirect(setting.AppSubUrl + "/user/login") |
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/user/login") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|