summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-10-12 04:59:21 +0800
committerGitHub <noreply@github.com>2023-10-11 22:59:21 +0200
commit63a321b83a6f3ed35f33316d61628d49e8612f66 (patch)
tree996f19cf4ebd1f1873d8031352cccdee1366d5f0 /routers
parent844ab9a4416b8c01772396663cd1b2cfaad8d0cf (diff)
downloadgitea-63a321b83a6f3ed35f33316d61628d49e8612f66.tar.gz
gitea-63a321b83a6f3ed35f33316d61628d49e8612f66.zip
Don't show Link to TOTP if not set up (#27585) (#27588)
Backport #27585 by @JakobDev Fixes https://codeberg.org/forgejo/forgejo/issues/1592 When login in with WebAuth, the page has a link to use TOTP instead. This link is always displayed, no matter if the User has set up TOTP or not, which do of cause not work for those who have not. Co-authored-by: JakobDev <jakobdev@gmx.de>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/auth/webauthn.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/routers/web/auth/webauthn.go b/routers/web/auth/webauthn.go
index 88413caea6..9b516ce396 100644
--- a/routers/web/auth/webauthn.go
+++ b/routers/web/auth/webauthn.go
@@ -37,6 +37,14 @@ func WebAuthn(ctx *context.Context) {
return
}
+ hasTwoFactor, err := auth.HasTwoFactorByUID(ctx, ctx.Session.Get("twofaUid").(int64))
+ if err != nil {
+ ctx.ServerError("HasTwoFactorByUID", err)
+ return
+ }
+
+ ctx.Data["HasTwoFactor"] = hasTwoFactor
+
ctx.HTML(http.StatusOK, tplWebAuthn)
}