1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-24 08:57:03 -05:00

Don't show Link to TOTP if not set up (#27585)

This commit is contained in:
JakobDev 2023-10-11 22:12:54 +02:00 committed by GitHub
parent 1d155a43ad
commit 328da56a28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -37,6 +37,14 @@ func WebAuthn(ctx *context.Context) {
return 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) ctx.HTML(http.StatusOK, tplWebAuthn)
} }

View file

@ -14,9 +14,11 @@
<div class="is-loading" style="width: 40px; height: 40px"></div> <div class="is-loading" style="width: 40px; height: 40px"></div>
{{ctx.Locale.Tr "webauthn_press_button"}} {{ctx.Locale.Tr "webauthn_press_button"}}
</div> </div>
{{if .HasTwoFactor}}
<div class="ui attached segment"> <div class="ui attached segment">
<a href="{{AppSubUrl}}/user/two_factor">{{ctx.Locale.Tr "webauthn_use_twofa"}}</a> <a href="{{AppSubUrl}}/user/two_factor">{{ctx.Locale.Tr "webauthn_use_twofa"}}</a>
</div> </div>
{{end}}
</div> </div>
</div> </div>
</div> </div>