diff --git a/routers/web/auth/webauthn.go b/routers/web/auth/webauthn.go index 88413caea69..9b516ce3963 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) } diff --git a/templates/user/auth/webauthn.tmpl b/templates/user/auth/webauthn.tmpl index f7389370259..722da02f543 100644 --- a/templates/user/auth/webauthn.tmpl +++ b/templates/user/auth/webauthn.tmpl @@ -14,9 +14,11 @@
{{ctx.Locale.Tr "webauthn_press_button"}} -
- {{ctx.Locale.Tr "webauthn_use_twofa"}} -
+ {{if .HasTwoFactor}} +
+ {{ctx.Locale.Tr "webauthn_use_twofa"}} +
+ {{end}}