Apply lstephan's suggestions
This commit is contained in:
parent
e3c3513a21
commit
8bf8700b36
1 changed files with 5 additions and 6 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue