mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-08-19 04:06:23 +02:00
Merge 0.2.17 release into develop
This commit is contained in:
21
helpdesk/views/login.py
Normal file
21
helpdesk/views/login.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import views as auth_views
|
||||
from django.contrib.auth.views import redirect_to_login
|
||||
from django.shortcuts import resolve_url
|
||||
|
||||
|
||||
default_login_view = auth_views.LoginView.as_view(
|
||||
template_name='helpdesk/registration/login.html')
|
||||
|
||||
|
||||
def login(request):
|
||||
login_url = settings.LOGIN_URL
|
||||
# Prevent redirect loop by checking that LOGIN_URL is not this view's name
|
||||
if login_url and login_url != request.resolver_match.view_name:
|
||||
if 'next' in request.GET:
|
||||
return_to = request.GET['next']
|
||||
else:
|
||||
return_to = resolve_url('helpdesk:home')
|
||||
return redirect_to_login(return_to, login_url)
|
||||
else:
|
||||
return default_login_view(request)
|
Reference in New Issue
Block a user