|
|
@@ -276,7 +276,7 @@ func SignInPostAPI(ctx *context.Context) { |
|
|
|
|
|
|
|
func SignInPostCommon(ctx *context.Context, form auth.SignInForm) { |
|
|
|
ctx.Data["Title"] = ctx.Tr("sign_in") |
|
|
|
|
|
|
|
log.Info("here111") |
|
|
|
orderedOAuth2Names, oauth2Providers, err := models.GetActiveOAuth2Providers() |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("UserSignIn", err) |
|
|
@@ -291,7 +291,7 @@ func SignInPostCommon(ctx *context.Context, form auth.SignInForm) { |
|
|
|
ctx.Data["IsCourse"] = ctx.QueryBool("course") |
|
|
|
ctx.Data["EnableSSPI"] = models.IsSSPIEnabled() |
|
|
|
ctx.Data["EnableCloudBrain"] = true |
|
|
|
|
|
|
|
log.Info("here222") |
|
|
|
if ctx.HasError() { |
|
|
|
ctx.HTML(200, tplSignIn) |
|
|
|
return |
|
|
@@ -326,6 +326,7 @@ func SignInPostCommon(ctx *context.Context, form auth.SignInForm) { |
|
|
|
return |
|
|
|
} |
|
|
|
models.SaveLoginInfoToDb(ctx.Req.Request, u) |
|
|
|
log.Info("here333") |
|
|
|
// If this user is enrolled in 2FA, we can't sign the user in just yet. |
|
|
|
// Instead, redirect them to the 2FA authentication page. |
|
|
|
_, err = models.GetTwoFactorByUID(u.ID) |
|
|
@@ -337,6 +338,7 @@ func SignInPostCommon(ctx *context.Context, form auth.SignInForm) { |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
log.Info("here444") |
|
|
|
// User needs to use 2FA, save data and redirect to 2FA page. |
|
|
|
if err := ctx.Session.Set("twofaUid", u.ID); err != nil { |
|
|
|
ctx.ServerError("UserSignIn: Unable to set twofaUid in session", err) |
|
|
@@ -368,6 +370,7 @@ func SignInCloudBrainPost(ctx *context.Context, form auth.SignInForm) { |
|
|
|
|
|
|
|
// SignInPost response for sign in request |
|
|
|
func SignInPost(ctx *context.Context, form auth.SignInForm) { |
|
|
|
log.Info("here99999") |
|
|
|
ctx.Data["PageIsLogin"] = true |
|
|
|
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login" |
|
|
|
ctx.Data["ActivityTpl"] = getActivityTpl() |
|
|
@@ -747,6 +750,7 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR |
|
|
|
|
|
|
|
// Register last login |
|
|
|
u.SetLastLogin() |
|
|
|
log.Info("77777_2222") |
|
|
|
if err := models.UpdateUserCols(u, "last_login_unix"); err != nil { |
|
|
|
ctx.ServerError("UpdateUserCols", err) |
|
|
|
return setting.AppSubURL + "/dashboard" |
|
|
@@ -758,14 +762,16 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR |
|
|
|
ctx.RedirectToFirst(redirectToCourse) |
|
|
|
return redirectToCourse |
|
|
|
} |
|
|
|
log.Info("77777_777") |
|
|
|
if redirectTo := ctx.GetCookie("redirect_to"); len(redirectTo) > 0 && !util.IsExternalURL(redirectTo) { |
|
|
|
log.Info("77777_8888") |
|
|
|
ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true) |
|
|
|
if obeyRedirect { |
|
|
|
ctx.RedirectToFirst(redirectTo) |
|
|
|
} |
|
|
|
return redirectTo |
|
|
|
} |
|
|
|
|
|
|
|
log.Info("77777_99999") |
|
|
|
if obeyRedirect { |
|
|
|
ctx.Redirect(setting.AppSubURL + "/dashboard") |
|
|
|
} |
|
|
|