diff options
author | Alexander_Kabui | 2024-09-18 16:09:48 +0300 |
---|---|---|
committer | Alexander_Kabui | 2024-09-18 16:09:48 +0300 |
commit | 88eae5f263bc816384fd124f06a28633ee8180ce (patch) | |
tree | e8944fa9c6f9d2a3dc03709cca38eac5a6e6265e /gn2/wqflask/oauth2 | |
parent | e751f31c1cc740f79adc630b4277e21aeab58b6d (diff) | |
download | genenetwork2-88eae5f263bc816384fd124f06a28633ee8180ce.tar.gz |
Refactor: try to build endpoint with get request.
If BuildError is raised default to "/"
Diffstat (limited to 'gn2/wqflask/oauth2')
-rw-r--r-- | gn2/wqflask/oauth2/checks.py | 7 |
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()) |