rename next_page_url → get_next_url
This commit is contained in:
parent
8bf8700b36
commit
1f631ebae2
1 changed files with 11 additions and 11 deletions
|
@ -9,7 +9,7 @@ from authens.utils import get_cas_client
|
|||
|
||||
|
||||
class NextPageMixin:
|
||||
def next_page_url(self):
|
||||
def get_next_url(self):
|
||||
"""Decide where to go after a successful login.
|
||||
|
||||
Look for (in order):
|
||||
|
@ -18,13 +18,13 @@ class NextPageMixin:
|
|||
- the `LOGIN_REDIRECT_URL` django setting.
|
||||
"""
|
||||
request = self.request
|
||||
next_page = request.GET.get("next")
|
||||
if next_page is None and "CASNEXT" in request.session:
|
||||
next_page = request.session["CASNEXT"]
|
||||
next_url = request.GET.get("next")
|
||||
if next_url is None and "CASNEXT" in request.session:
|
||||
next_url = request.session["CASNEXT"]
|
||||
del request.session["CASNEXT"]
|
||||
if next_page is None:
|
||||
next_page = settings.LOGIN_REDIRECT_URL
|
||||
return next_page
|
||||
if next_url is None:
|
||||
next_url = settings.LOGIN_REDIRECT_URL
|
||||
return next_url
|
||||
|
||||
|
||||
class LoginSwitchView(NextPageMixin, TemplateView):
|
||||
|
@ -35,12 +35,12 @@ class LoginSwitchView(NextPageMixin, TemplateView):
|
|||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if request.user.is_authenticated:
|
||||
return redirect(self.next_page_url())
|
||||
return redirect(self.get_next_url())
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx["next_page"] = self.next_page_url()
|
||||
ctx["next_page"] = self.get_next_url()
|
||||
return ctx
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ class CASLoginView(NextPageMixin, View):
|
|||
ticket = request.GET.get("ticket")
|
||||
|
||||
if not ticket:
|
||||
request.session["CASNEXT"] = self.next_page_url()
|
||||
request.session["CASNEXT"] = self.get_next_url()
|
||||
cas_client = get_cas_client(request)
|
||||
return redirect(cas_client.get_login_url())
|
||||
|
||||
|
@ -69,7 +69,7 @@ class CASLoginView(NextPageMixin, View):
|
|||
if user is None:
|
||||
raise PermissionDenied(_("Connection échouée !"))
|
||||
auth.login(request, user)
|
||||
return redirect(self.next_page_url())
|
||||
return redirect(self.get_next_url())
|
||||
|
||||
|
||||
class PasswordLoginView(auth.views.LoginView):
|
||||
|
|
Loading…
Reference in a new issue