summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2020-04-02 19:50:13 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2020-04-03 06:26:20 (GMT)
commitbf1864f324e5984bfb9014562ca2c44fdd2afe08 (patch)
treee8d1e063919d747e9090547ed18e4ad8f816a571
parent72f29fcd68dc60fed12a388c59f8b5189dc5c28f (diff)
downloadwelco-bf1864f324e5984bfb9014562ca2c44fdd2afe08.zip
welco-bf1864f324e5984bfb9014562ca2c44fdd2afe08.tar.gz
welco-bf1864f324e5984bfb9014562ca2c44fdd2afe08.tar.bz2
misc: use new login class based view (#41286)
-rw-r--r--welco/views.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/welco/views.py b/welco/views.py
index b8d7ae5..7fc6f95 100644
--- a/welco/views.py
+++ b/welco/views.py
@@ -47,13 +47,23 @@ from .contacts.views import HomeZone as ContactsHomeZone
from .forms import QualificationForm
-def login(request, *args, **kwargs):
- if any(get_idps()):
- if not 'next' in request.GET:
- return HttpResponseRedirect(resolve_url('mellon_login'))
- return HttpResponseRedirect(resolve_url('mellon_login') + '?next='
- + quote(request.GET.get('next')))
- return auth_views.login(request, template_name='welco/login.html')
+class LoginView(auth_views.LoginView):
+ template_name = 'welco/login.html'
+
+ def dispatch(self, request, *args, **kwargs):
+ if any(get_idps()):
+ if 'next' not in request.GET:
+ return HttpResponseRedirect(resolve_url('mellon_login'))
+ try:
+ quoted_next_url = quote(request.GET.get('next'))
+ except KeyError:
+ return HttpResponseBadRequest('invalid value for "next" parameter')
+ return HttpResponseRedirect(resolve_url('mellon_login') + '?next=' + quoted_next_url)
+ return super(LoginView, self).dispatch(request, *args, **kwargs)
+
+
+login = LoginView.as_view()
+
def logout(request, next_page=None):
if any(get_idps()):