From 8bf8700b369f2d62e6a98a2d1fdc74706b67f696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 13 May 2020 13:25:47 +0200 Subject: [PATCH] Apply lstephan's suggestions --- authens/views.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/authens/views.py b/authens/views.py index eee4007..772a68d 100644 --- a/authens/views.py +++ b/authens/views.py @@ -1,7 +1,7 @@ from django.conf import settings from django.contrib import auth from django.core.exceptions import PermissionDenied -from django.views.generic import RedirectView, TemplateView +from django.views.generic import TemplateView, View from django.shortcuts import redirect from django.utils.translation import gettext_lazy as _ @@ -44,7 +44,7 @@ class LoginSwitchView(NextPageMixin, TemplateView): return ctx -class CASLoginView(NextPageMixin, RedirectView): +class CASLoginView(NextPageMixin, View): """CAS authentication view. Implement the CAS authentication scheme: @@ -57,20 +57,19 @@ class CASLoginView(NextPageMixin, RedirectView): http_method_names = ["get"] - def get_redirect_url(self, *args, **kwargs): - request = self.request + def get(self, request, *args, **kwargs): ticket = request.GET.get("ticket") if not ticket: request.session["CASNEXT"] = self.next_page_url() cas_client = get_cas_client(request) - return cas_client.get_login_url() + return redirect(cas_client.get_login_url()) user = auth.authenticate(request, ticket=ticket) if user is None: raise PermissionDenied(_("Connection échouée !")) auth.login(request, user) - return self.next_page_url() + return redirect(self.next_page_url()) class PasswordLoginView(auth.views.LoginView):