mirror of
https://github.com/DMOJ/online-judge.git
synced 2024-11-25 16:32:37 +08:00
Change "Refresh" to "Edit" 2FA on profile page
This commit is contained in:
parent
19e7a0943b
commit
18e49e0956
@ -66,7 +66,7 @@ register_patterns = [
|
||||
|
||||
path('2fa/', two_factor.TwoFactorLoginView.as_view(), name='login_2fa'),
|
||||
path('2fa/enable/', two_factor.TOTPEnableView.as_view(), name='enable_2fa'),
|
||||
path('2fa/refresh/', two_factor.TOTPRefreshView.as_view(), name='refresh_2fa'),
|
||||
path('2fa/edit/', two_factor.TOTPEditView.as_view(), name='edit_2fa'),
|
||||
path('2fa/disable/', two_factor.TOTPDisableView.as_view(), name='disable_2fa'),
|
||||
path('2fa/webauthn/attest/', two_factor.WebAuthnAttestationView.as_view(), name='webauthn_attest'),
|
||||
path('2fa/webauthn/assert/', two_factor.WebAuthnAttestView.as_view(), name='webauthn_assert'),
|
||||
|
@ -50,7 +50,7 @@ class TOTPEnableView(TOTPView):
|
||||
title = gettext_lazy('Enable Two-factor Authentication')
|
||||
form_class = TOTPEnableForm
|
||||
template_name = 'registration/totp_enable.html'
|
||||
is_refresh = False
|
||||
is_edit = False
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
profile = self.profile
|
||||
@ -76,9 +76,9 @@ class TOTPEnableView(TOTPView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(TOTPEnableView, self).get_context_data(**kwargs)
|
||||
context['totp_key'] = self.request.session['totp_enable_key']
|
||||
context['scratch_codes'] = [] if self.is_refresh else json.loads(self.profile.scratch_codes)
|
||||
context['scratch_codes'] = [] if self.is_edit else json.loads(self.profile.scratch_codes)
|
||||
context['qr_code'] = self.render_qr_code(self.request.user.username, context['totp_key'])
|
||||
context['is_refresh'] = self.is_refresh
|
||||
context['is_edit'] = self.is_edit
|
||||
context['is_hardcore'] = settings.DMOJ_2FA_HARDCORE
|
||||
return context
|
||||
|
||||
@ -106,9 +106,9 @@ class TOTPEnableView(TOTPView):
|
||||
return 'data:image/png;base64,' + base64.b64encode(buf.getvalue()).decode('ascii')
|
||||
|
||||
|
||||
class TOTPRefreshView(TOTPEnableView):
|
||||
title = gettext_lazy('Refresh Two-factor Authentication')
|
||||
is_refresh = True
|
||||
class TOTPEditView(TOTPEnableView):
|
||||
title = gettext_lazy('Edit Two-factor Authentication')
|
||||
is_edit = True
|
||||
|
||||
def check_skip(self):
|
||||
return not self.profile.is_totp_enabled
|
||||
|
@ -86,8 +86,8 @@
|
||||
<span class="fullwidth">{{ form.totp_or_scratch_code }}</span>
|
||||
</div>
|
||||
<button style="margin-top: 0.5em" class="button" type="submit">
|
||||
{%- if is_refresh -%}
|
||||
{{ _('Refresh Two Factor Authentication') }}
|
||||
{%- if is_edit -%}
|
||||
{{ _('Edit Two Factor Authentication') }}
|
||||
{%- else -%}
|
||||
{{ _('Enable Two Factor Authentication') }}
|
||||
{%- endif -%}
|
||||
|
@ -379,7 +379,7 @@
|
||||
<a href="{{ url('disable_2fa') }}"
|
||||
class="button inline-button">{{ _('Disable') }}</a>
|
||||
{% endif %}
|
||||
<a href="{{ url('refresh_2fa') }}" class="button inline-button">{{ _('Refresh') }}</a>
|
||||
<a href="{{ url('edit_2fa') }}" class="button inline-button">{{ _('Edit') }}</a>
|
||||
</div>
|
||||
<div class="block-header grayed">
|
||||
{{ _('Scratch codes:') }}
|
||||
|
Loading…
Reference in New Issue
Block a user