Merge branch 'main' into pilot-lafede
This commit is contained in:
commit
a0bd339ab5
|
@ -4,8 +4,6 @@
|
||||||
{% block login_content %}
|
{% block login_content %}
|
||||||
<form action="{% url 'idhub:login' %}" role="form" method="post">
|
<form action="{% url 'idhub:login' %}" role="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="next" value="{{ next }}" />
|
|
||||||
|
|
||||||
<div id="div_id_username"
|
<div id="div_id_username"
|
||||||
class="clearfix control-group {% if form.username.errors %}error{% endif %}">
|
class="clearfix control-group {% if form.username.errors %}error{% endif %}">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
@ -13,16 +13,16 @@ class LoginView(auth_views.LoginView):
|
||||||
}
|
}
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
if request.GET.get('next'):
|
self.extra_context['success_url'] = request.GET.get(
|
||||||
self.extra_context['success_url'] = request.GET.get('next')
|
'next',
|
||||||
|
reverse_lazy('idhub:user_dashboard')
|
||||||
|
)
|
||||||
return super().get(request, *args, **kwargs)
|
return super().get(request, *args, **kwargs)
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
user = form.get_user()
|
user = form.get_user()
|
||||||
if not user.is_anonymous and user.is_admin:
|
if not user.is_anonymous and user.is_admin:
|
||||||
user_dashboard = reverse_lazy('idhub:user_dashboard')
|
|
||||||
admin_dashboard = reverse_lazy('idhub:admin_dashboard')
|
admin_dashboard = reverse_lazy('idhub:admin_dashboard')
|
||||||
if self.extra_context['success_url'] == user_dashboard:
|
|
||||||
self.extra_context['success_url'] = admin_dashboard
|
self.extra_context['success_url'] = admin_dashboard
|
||||||
auth_login(self.request, user)
|
auth_login(self.request, user)
|
||||||
return HttpResponseRedirect(self.extra_context['success_url'])
|
return HttpResponseRedirect(self.extra_context['success_url'])
|
||||||
|
|
Loading…
Reference in a new issue