diff options
author | Kamil DomaĆski <kamil@domanski.co> | 2021-11-08 23:47:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-08 23:47:19 +0100 |
commit | 021df29623bb0155b5a2ccad0e5f90fb348c8f4e (patch) | |
tree | c720bc34bd29620028c51d35c6d98044af89101e /templates/user | |
parent | a3f9e9234cbb099b821a6ea9c575927be18948de (diff) | |
download | gitea-021df29623bb0155b5a2ccad0e5f90fb348c8f4e.tar.gz gitea-021df29623bb0155b5a2ccad0e5f90fb348c8f4e.zip |
Allow U2F 2FA without TOTP (#11573)
This change enables the usage of U2F without being forced to enroll an TOTP authenticator.
The `/user/auth/u2f` has been changed to hide the "use TOTP instead" bar if TOTP is not enrolled.
Fixes #5410
Fixes #17495
Diffstat (limited to 'templates/user')
-rw-r--r-- | templates/user/auth/u2f.tmpl | 8 | ||||
-rw-r--r-- | templates/user/settings/security_twofa.tmpl | 2 | ||||
-rw-r--r-- | templates/user/settings/security_u2f.tmpl | 42 |
3 files changed, 25 insertions, 27 deletions
diff --git a/templates/user/auth/u2f.tmpl b/templates/user/auth/u2f.tmpl index 2013d14937..8b04866bbc 100644 --- a/templates/user/auth/u2f.tmpl +++ b/templates/user/auth/u2f.tmpl @@ -12,9 +12,11 @@ <p>{{.i18n.Tr "u2f_sign_in"}}</p> </div> <div id="wait-for-key" class="ui attached segment"><div class="ui active indeterminate inline loader"></div> {{.i18n.Tr "u2f_press_button"}} </div> - <div class="ui attached segment"> - <a href="{{AppSubUrl}}/user/two_factor">{{.i18n.Tr "u2f_use_twofa"}}</a> - </div> + {{if .TOTPEnrolled}} + <div class="ui attached segment"> + <a href="{{AppSubUrl}}/user/two_factor">{{.i18n.Tr "u2f_use_twofa"}}</a> + </div> + {{end}} </div> </div> </div> diff --git a/templates/user/settings/security_twofa.tmpl b/templates/user/settings/security_twofa.tmpl index f48b2f4cb2..3d6804d9c6 100644 --- a/templates/user/settings/security_twofa.tmpl +++ b/templates/user/settings/security_twofa.tmpl @@ -3,7 +3,7 @@ </h4> <div class="ui attached segment"> <p>{{.i18n.Tr "settings.twofa_desc"}}</p> - {{if .TwofaEnrolled}} + {{if .TOTPEnrolled}} <p>{{$.i18n.Tr "settings.twofa_is_enrolled" | Str2html }}</p> <form class="ui form" action="{{AppSubUrl}}/user/settings/security/two_factor/regenerate_scratch" method="post" enctype="multipart/form-data"> {{.CsrfTokenHtml}} diff --git a/templates/user/settings/security_u2f.tmpl b/templates/user/settings/security_u2f.tmpl index 8fe01d8c70..a2ff6c2212 100644 --- a/templates/user/settings/security_u2f.tmpl +++ b/templates/user/settings/security_u2f.tmpl @@ -3,32 +3,28 @@ </h4> <div class="ui attached segment"> <p>{{.i18n.Tr "settings.u2f_desc" | Str2html}}</p> - {{if .TwofaEnrolled}} - <div class="ui key list"> - {{range .U2FRegistrations}} - <div class="item"> - <div class="right floated content"> - <button class="ui red tiny button delete-button" data-modal-id="delete-registration" data-url="{{$.Link}}/u2f/delete" data-id="{{.ID}}"> - {{$.i18n.Tr "settings.delete_key"}} - </button> - </div> - <div class="content"> - <strong>{{.Name}}</strong> - </div> + <div class="ui key list"> + {{range .U2FRegistrations}} + <div class="item"> + <div class="right floated content"> + <button class="ui red tiny button delete-button" id="delete-registration" data-url="{{$.Link}}/u2f/delete" data-id="{{.ID}}"> + {{$.i18n.Tr "settings.delete_key"}} + </button> + </div> + <div class="content"> + <strong>{{.Name}}</strong> </div> - {{end}} - </div> - <div class="ui form"> - {{.CsrfTokenHtml}} - <div class="required field"> - <label for="nickname">{{.i18n.Tr "settings.u2f_nickname"}}</label> - <input id="nickname" name="nickname" type="text" required> </div> - <button id="register-security-key" class="ui green button">{{svg "octicon-key"}} {{.i18n.Tr "settings.u2f_register_key"}}</button> + {{end}} + </div> + <div class="ui form"> + {{.CsrfTokenHtml}} + <div class="required field"> + <label for="nickname">{{.i18n.Tr "settings.u2f_nickname"}}</label> + <input id="nickname" name="nickname" type="text" required> </div> - {{else}} - <b>{{.i18n.Tr "settings.u2f_require_twofa"}}</b> - {{end}} + <button id="register-security-key" class="ui green button">{{svg "octicon-key"}} {{.i18n.Tr "settings.u2f_register_key"}}</button> + </div> </div> <div class="ui small modal" id="register-device"> |