Implement name display in login views

This commit is contained in:
Kumi 2020-05-23 12:04:09 +02:00
parent f4aab6ee57
commit e924e18234
3 changed files with 9 additions and 2 deletions

View file

@ -38,6 +38,7 @@ class LoginView(FormView):
self.request.session["otpsession"] = str(session.uuid)
self.request.session["next"] = self.request.GET.get("next", "dashboard")
return redirect("otpselector")
messages.error(self.request, "The credentials you entered are invalid. Please try again.")
return super().form_invalid(form)
class OTPSelectorView(FormView):
@ -72,6 +73,9 @@ class OTPSelectorView(FormView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Two-Factor Authentication"
user = LoginSession.objects.get(uuid=self.request.session["otpsession"]).user
context["first_name"] = user.profile.get_internal_name
return context
class OTPValidatorView(FormView):
@ -125,6 +129,9 @@ class OTPValidatorView(FormView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Two-Factor Authentication"
user, provider = self.validate_session(self.request)
context["first_name"] = user.profile.get_internal_name
return context
class LogoutView(View):

View file

@ -4,7 +4,7 @@
<div class="mx-auto app-login-box col-sm-12 col-md-10 col-lg-9">
<div class="app-logo"></div>
<h4 class="mb-0">
<span class="d-block">Welcome back {{ request.user.first_name }},</span>
<span class="d-block">Welcome back {{ first_name }},</span>
<span>Please select your Two-Factor Authentication provider</span></h4>
{% bootstrap_messages %}
<div class="divider row"></div>

View file

@ -4,7 +4,7 @@
<div class="mx-auto app-login-box col-sm-12 col-md-10 col-lg-9">
<div class="app-logo"></div>
<h4 class="mb-0">
<span class="d-block">Welcome back {{ request.user.first_name }},</span>
<span class="d-block">Welcome back {{ first_name }},</span>
<span>Please enter your OTP Token</span></h4>
{% bootstrap_messages %}
<div class="divider row"></div>