Implement name display in login views
This commit is contained in:
parent
f4aab6ee57
commit
e924e18234
3 changed files with 9 additions and 2 deletions
|
@ -38,6 +38,7 @@ class LoginView(FormView):
|
||||||
self.request.session["otpsession"] = str(session.uuid)
|
self.request.session["otpsession"] = str(session.uuid)
|
||||||
self.request.session["next"] = self.request.GET.get("next", "dashboard")
|
self.request.session["next"] = self.request.GET.get("next", "dashboard")
|
||||||
return redirect("otpselector")
|
return redirect("otpselector")
|
||||||
|
messages.error(self.request, "The credentials you entered are invalid. Please try again.")
|
||||||
return super().form_invalid(form)
|
return super().form_invalid(form)
|
||||||
|
|
||||||
class OTPSelectorView(FormView):
|
class OTPSelectorView(FormView):
|
||||||
|
@ -72,6 +73,9 @@ class OTPSelectorView(FormView):
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["title"] = "Two-Factor Authentication"
|
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
|
return context
|
||||||
|
|
||||||
class OTPValidatorView(FormView):
|
class OTPValidatorView(FormView):
|
||||||
|
@ -125,6 +129,9 @@ class OTPValidatorView(FormView):
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["title"] = "Two-Factor Authentication"
|
context["title"] = "Two-Factor Authentication"
|
||||||
|
|
||||||
|
user, provider = self.validate_session(self.request)
|
||||||
|
context["first_name"] = user.profile.get_internal_name
|
||||||
return context
|
return context
|
||||||
|
|
||||||
class LogoutView(View):
|
class LogoutView(View):
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="mx-auto app-login-box col-sm-12 col-md-10 col-lg-9">
|
<div class="mx-auto app-login-box col-sm-12 col-md-10 col-lg-9">
|
||||||
<div class="app-logo"></div>
|
<div class="app-logo"></div>
|
||||||
<h4 class="mb-0">
|
<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>
|
<span>Please select your Two-Factor Authentication provider</span></h4>
|
||||||
{% bootstrap_messages %}
|
{% bootstrap_messages %}
|
||||||
<div class="divider row"></div>
|
<div class="divider row"></div>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="mx-auto app-login-box col-sm-12 col-md-10 col-lg-9">
|
<div class="mx-auto app-login-box col-sm-12 col-md-10 col-lg-9">
|
||||||
<div class="app-logo"></div>
|
<div class="app-logo"></div>
|
||||||
<h4 class="mb-0">
|
<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>
|
<span>Please enter your OTP Token</span></h4>
|
||||||
{% bootstrap_messages %}
|
{% bootstrap_messages %}
|
||||||
<div class="divider row"></div>
|
<div class="divider row"></div>
|
||||||
|
|
Loading…
Reference in a new issue