summaryrefslogtreecommitdiffstats
path: root/routers/web/auth/linkaccount.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/web/auth/linkaccount.go')
-rw-r--r--routers/web/auth/linkaccount.go22
1 files changed, 6 insertions, 16 deletions
diff --git a/routers/web/auth/linkaccount.go b/routers/web/auth/linkaccount.go
index 4f3f2062b6..d3211eaa5c 100644
--- a/routers/web/auth/linkaccount.go
+++ b/routers/web/auth/linkaccount.go
@@ -18,7 +18,6 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/mcaptcha"
"code.gitea.io/gitea/modules/recaptcha"
- "code.gitea.io/gitea/modules/session"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/web"
auth_service "code.gitea.io/gitea/services/auth"
@@ -156,25 +155,16 @@ func linkAccount(ctx *context.Context, u *user_model.User, gothUser goth.User, r
return
}
- if _, err := session.RegenerateSession(ctx.Resp, ctx.Req); err != nil {
+ if err := updateSession(ctx, nil, map[string]interface{}{
+ // User needs to use 2FA, save data and redirect to 2FA page.
+ "twofaUid": u.ID,
+ "twofaRemember": remember,
+ "linkAccount": true,
+ }); err != nil {
ctx.ServerError("RegenerateSession", err)
return
}
- // User needs to use 2FA, save data and redirect to 2FA page.
- if err := ctx.Session.Set("twofaUid", u.ID); err != nil {
- log.Error("Error setting twofaUid in session: %v", err)
- }
- if err := ctx.Session.Set("twofaRemember", remember); err != nil {
- log.Error("Error setting twofaRemember in session: %v", err)
- }
- if err := ctx.Session.Set("linkAccount", true); err != nil {
- log.Error("Error setting linkAccount in session: %v", err)
- }
- if err := ctx.Session.Release(); err != nil {
- log.Error("Error storing session: %v", err)
- }
-
// If WebAuthn is enrolled -> Redirect to WebAuthn instead
regs, err := auth.GetWebAuthnCredentialsByUID(u.ID)
if err == nil && len(regs) > 0 {