mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 01:27:03 +02:00
Fix linter errors
This commit is contained in:
parent
00f87168e5
commit
f16d657c6a
5 changed files with 101 additions and 97 deletions
|
@ -2,18 +2,13 @@
|
|||
|
||||
import logging
|
||||
|
||||
try:
|
||||
from urllib.parse import parse_qs, urlencode
|
||||
except ImportError:
|
||||
from urllib import urlencode
|
||||
from urlparse import parse_qs
|
||||
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import logout as auth_logout
|
||||
from django.contrib.auth import authenticate, login
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import redirect, render
|
||||
from urllib.parse import parse_qs, urlencode
|
||||
|
||||
from djangooidc.oidc import Client
|
||||
from djangooidc import exceptions as o_e
|
||||
|
||||
|
@ -35,9 +30,9 @@ def error_page(request, error):
|
|||
"401.html",
|
||||
context={
|
||||
"friendly_message": error.friendly_message,
|
||||
"log_identifier": error.locator
|
||||
"log_identifier": error.locator,
|
||||
},
|
||||
status=401
|
||||
status=401,
|
||||
)
|
||||
if isinstance(error, o_e.InternalError):
|
||||
return render(
|
||||
|
@ -45,13 +40,14 @@ def error_page(request, error):
|
|||
"500.html",
|
||||
context={
|
||||
"friendly_message": error.friendly_message,
|
||||
"log_identifier": error.locator
|
||||
"log_identifier": error.locator,
|
||||
},
|
||||
status=500
|
||||
status=500,
|
||||
)
|
||||
if isinstance(error, Exception):
|
||||
return render(request, "500.html", status=500)
|
||||
|
||||
|
||||
def openid(request):
|
||||
"""Redirect the user to an authentication provider (OP)."""
|
||||
request.session["next"] = request.GET.get("next", "/")
|
||||
|
@ -61,6 +57,7 @@ def openid(request):
|
|||
except Exception as err:
|
||||
return error_page(request, err)
|
||||
|
||||
|
||||
def login_callback(request):
|
||||
"""Analyze the token returned by the authentication provider (OP)."""
|
||||
try:
|
||||
|
@ -90,11 +87,13 @@ def logout(request, next_page=None):
|
|||
"post_logout_redirect_uris" in CLIENT.registration_response.keys()
|
||||
and len(CLIENT.registration_response["post_logout_redirect_uris"]) > 0
|
||||
):
|
||||
request_args.update({
|
||||
"post_logout_redirect_uri":
|
||||
CLIENT.registration_response["post_logout_redirect_uris"][0]
|
||||
})
|
||||
|
||||
request_args.update(
|
||||
{
|
||||
"post_logout_redirect_uri": CLIENT.registration_response[
|
||||
"post_logout_redirect_uris"
|
||||
][0]
|
||||
}
|
||||
)
|
||||
|
||||
url = CLIENT.provider_info["end_session_endpoint"]
|
||||
url += "?" + urlencode(request_args)
|
||||
|
@ -110,6 +109,7 @@ def logout(request, next_page=None):
|
|||
if next_page:
|
||||
request.session["next"] = next_page
|
||||
|
||||
|
||||
def logout_callback(request):
|
||||
"""Simple redirection view: after logout, redirect to `next`."""
|
||||
next = request.session["next"] if "next" in request.session.keys() else "/"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue