Fix login redirect
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful

This commit is contained in:
Madis Mägi 2024-07-27 17:38:10 +03:00
parent 2aa75d9e4b
commit fb4470fcde

View File

@ -20,8 +20,6 @@ def login_required(_f=None, *, groups=[]):
print(groups)
user = read_user()
if not user:
print("doing login redirect")
session["original_url"] = request.full_path
return do_login()
if groups and not any(group in groups for group in user["groups"]):
return "not allowed", 401
@ -34,6 +32,10 @@ def login_required(_f=None, *, groups=[]):
return login_required_inner(_f)
def do_login():
print("doing login redirect")
if request and request.full_path:
print("storing url: " + request.full_path)
session["original_url"] = request.full_path
url = add_url_params(metadata["authorization_endpoint"], {
"client_id": os.getenv("OIDC_CLIENT_ID"),
"redirect_uri": url_for("oidc.login_callback", _external=True, _scheme='https'),
@ -64,6 +66,7 @@ def login_callback():
print("authenticated")
session["id_token"] = r["id_token"]
session["access_token"] = r["access_token"]
print("stored url was: " + session.get("original_url"))
return redirect(session.pop("original_url", "/"))
@page_oidc.route("/logout")