Commit 5e0a765a by Kálmán Viktor

dashboard: nicer 2fa login page

parent b83e5628
......@@ -1670,9 +1670,8 @@ class TwoFactorForm(ModelForm):
class TwoFactorConfirmationForm(forms.Form):
confirmation_code = forms.CharField(
label=_('Confirmation code'),
help_text=_("Get the code from your authenticator to disable "
"two-factor authentication."))
label=_('Two-factor authentication passcode'),
help_text=_("Get the code from your authenticator."))
def __init__(self, user, *args, **kwargs):
self.user = user
......
......@@ -1549,3 +1549,17 @@ textarea[name="new_members"] {
margin-left: 15px;
}
}
#two-factor-box {
.help-block {
display: block;
}
h4 {
margin: 0;
}
hr {
margin: 15px 0 2px 0;
}
}
......@@ -622,15 +622,21 @@ class TwoFactorLoginView(FormView):
return super(TwoFactorLoginView, self).dispatch(*args, **kwargs)
def get_user(self):
return User.objects.get(pk=self.request.session['two-fa-user'])
def get_form_kwargs(self):
kwargs = super(TwoFactorLoginView, self).get_form_kwargs()
user_pk = self.request.session['two-fa-user']
kwargs['user'] = User.objects.get(pk=user_pk)
kwargs['user'] = self.get_user()
return kwargs
def get_context_data(self, **kwargs):
ctx = super(TwoFactorLoginView, self).get_context_data(**kwargs)
ctx['user'] = self.get_user()
return ctx
def form_valid(self, form):
user_pk = self.request.session['two-fa-user']
user = User.objects.get(pk=user_pk)
user = self.get_user()
if self.request.session['login-type'] == "saml2":
user.backend = 'common.backends.Saml2Backend'
......
......@@ -4,21 +4,24 @@
{% load crispy_forms_tags %}
{% get_current_language as LANGUAGE_CODE %}
{% block title-page %}{% trans "Login" %}{% endblock %}
{% block title-page %}{% trans "Two-factor authentication" %}{% endblock %}
{% block content_box %}
<div class="row">
<div class="row" id="two-factor-box">
<div class="col-md-12">
<h4>
{% blocktrans with username=user.username full_name=user.get_full_name %}
Welcome {{ full_name }} ({{ username }})!
{% endblocktrans %}
</h4>
<hr/>
<form action="" method="POST">
{% csrf_token %}
{{ form.confirmation_code|as_crispy_field }}
<input type="submit"/>
<button type="submit" class="btn btn-success">
{% trans "Confirm" %}
</button>
</form>
</div>
</div>
<style>
.help-block {
display: block;
}
</style>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment