Simplify the code

This commit is contained in:
Antonin Reitz 2019-11-27 11:51:29 +01:00
parent f8ebff12f3
commit 27c7a47c46

View file

@ -66,23 +66,13 @@ class GenericLoginView(View):
# Issue token.
token = GenericTeamToken.objects.create_token()
# Prepare callback of logout.
here_url = reverse(login_generic)
if "next" in self.request.GET:
# Keep given next page.
here_qd = QueryDict(mutable=True)
here_qd["next"] = self.request.GET["next"]
here_url += "?{}".format(here_qd.urlencode())
# When CAS logs the user out, the generic login has to be called back.
# The corresponding callback URL is provided as a GET parameter.
# The renaming of the CAS logout "url" parameter to "service" is being forced,
# which is why the CAS logout URL with callback is constructed ad hoc,
# without relying on Django redirection to Django CAS.
# An HTTP absolute URL as callback seems to be required for the K-Psul link
# to work.
generic_login_url = "http://" + request.get_host() + here_url
generic_login_url = request.build_absolute_uri() # preserves next parameter
generic_login_qd = QueryDict(mutable=True)
generic_login_qd["service"] = generic_login_url