Skip to content

Commit 328da56

Browse files
authored
Don't show Link to TOTP if not set up (#27585)
1 parent 1d155a4 commit 328da56

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

routers/web/auth/webauthn.go

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ func WebAuthn(ctx *context.Context) {
3737
return
3838
}
3939

40+
hasTwoFactor, err := auth.HasTwoFactorByUID(ctx, ctx.Session.Get("twofaUid").(int64))
41+
if err != nil {
42+
ctx.ServerError("HasTwoFactorByUID", err)
43+
return
44+
}
45+
46+
ctx.Data["HasTwoFactor"] = hasTwoFactor
47+
4048
ctx.HTML(http.StatusOK, tplWebAuthn)
4149
}
4250

templates/user/auth/webauthn.tmpl

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
<div class="is-loading" style="width: 40px; height: 40px"></div>
1515
{{ctx.Locale.Tr "webauthn_press_button"}}
1616
</div>
17-
<div class="ui attached segment">
18-
<a href="{{AppSubUrl}}/user/two_factor">{{ctx.Locale.Tr "webauthn_use_twofa"}}</a>
19-
</div>
17+
{{if .HasTwoFactor}}
18+
<div class="ui attached segment">
19+
<a href="{{AppSubUrl}}/user/two_factor">{{ctx.Locale.Tr "webauthn_use_twofa"}}</a>
20+
</div>
21+
{{end}}
2022
</div>
2123
</div>
2224
</div>

0 commit comments

Comments
 (0)