]> source.dussan.org Git - gitea.git/commitdiff
Don't show Link to TOTP if not set up (#27585)
authorJakobDev <jakobdev@gmx.de>
Wed, 11 Oct 2023 20:12:54 +0000 (22:12 +0200)
committerGitHub <noreply@github.com>
Wed, 11 Oct 2023 20:12:54 +0000 (20:12 +0000)
routers/web/auth/webauthn.go
templates/user/auth/webauthn.tmpl

index 88413caea6971e632aeb3c7f94d259e396aec1e7..9b516ce3963ef78876e11dd731e0df6823c37b09 100644 (file)
@@ -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)
 }
 
index f738937025998bac3f12533ab7721735f27a12bc..722da02f5438c50c5b6d338aaeb2ebd63fba943a 100644 (file)
                                <div class="is-loading" style="width: 40px; height: 40px"></div>
                                {{ctx.Locale.Tr "webauthn_press_button"}}
                        </div>
-                       <div class="ui attached segment">
-                               <a href="{{AppSubUrl}}/user/two_factor">{{ctx.Locale.Tr "webauthn_use_twofa"}}</a>
-                       </div>
+                       {{if .HasTwoFactor}}
+                               <div class="ui attached segment">
+                                       <a href="{{AppSubUrl}}/user/two_factor">{{ctx.Locale.Tr "webauthn_use_twofa"}}</a>
+                               </div>
+                       {{end}}
                </div>
        </div>
 </div>