21 lines
698 B
Python
21 lines
698 B
Python
from django.urls import reverse_lazy
|
|
from django.utils.translation import gettext_lazy as _
|
|
from django.contrib.auth import views as auth_views
|
|
|
|
|
|
class LoginView(auth_views.LoginView):
|
|
template_name = 'auth/login.html'
|
|
extra_context = {
|
|
'title': _('Login'),
|
|
'success_url': reverse_lazy('idhub:user_dashboard'),
|
|
}
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
if request.user.is_admin:
|
|
self.extra_context['success_url'] = reverse_lazy(
|
|
'idhub:admin_dashboard'
|
|
)
|
|
if request.GET.get('next'):
|
|
self.extra_context['success_url'] = request.GET.get('next')
|
|
return super().get(request, *args, **kwargs)
|