aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander_Kabui2024-09-18 16:09:48 +0300
committerAlexander_Kabui2024-09-18 16:09:48 +0300
commit88eae5f263bc816384fd124f06a28633ee8180ce (patch)
treee8944fa9c6f9d2a3dc03709cca38eac5a6e6265e
parente751f31c1cc740f79adc630b4277e21aeab58b6d (diff)
downloadgenenetwork2-88eae5f263bc816384fd124f06a28633ee8180ce.tar.gz
Refactor: try to build endpoint with get request.
If BuildError is raised default to "/"
-rw-r--r--gn2/wqflask/oauth2/checks.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/gn2/wqflask/oauth2/checks.py b/gn2/wqflask/oauth2/checks.py
index 55338930..8a6e439e 100644
--- a/gn2/wqflask/oauth2/checks.py
+++ b/gn2/wqflask/oauth2/checks.py
@@ -4,6 +4,7 @@ from urllib.parse import urljoin
from flask import flash, request, redirect, url_for
from authlib.integrations.requests_client import OAuth2Session
+from werkzeug.routing import BuildError
from . import session
from .client import (
@@ -30,9 +31,9 @@ def require_oauth2(func):
Save the current user request to session then
redirect to the login page.
"""
- if request.method == "GET":
- redirect_url = url_for(request.endpoint, **request.args)
- else:
+ try:
+ redirect_url = url_for(request.endpoint, _method="GET", **request.args)
+ except BuildError:
redirect_url = "/"
session.set_redirect_url(redirect_url)
return redirect(authserver_authorise_uri())