more explicit naming, query param handling for login redirects
This commit is contained in:
parent
4eaea6c055
commit
509b4c55a2
@ -20,7 +20,8 @@ def root():
|
||||
redirect_url = app.config.get("CAC_URL")
|
||||
if request.args.get("next"):
|
||||
redirect_url = url.urljoin(
|
||||
redirect_url, "?{}".format(url.urlencode(request.args))
|
||||
redirect_url,
|
||||
"?{}".format(url.urlencode({"next": request.args.get("next")})),
|
||||
)
|
||||
|
||||
return render_template(
|
||||
@ -80,11 +81,11 @@ def _make_authentication_context():
|
||||
)
|
||||
|
||||
|
||||
def redirect_url():
|
||||
def redirect_after_login_url():
|
||||
if request.args.get("next"):
|
||||
return request.args.get("next")
|
||||
else:
|
||||
return url_for(".home")
|
||||
return url_for("atst.home")
|
||||
|
||||
|
||||
@bp.route("/login-redirect")
|
||||
@ -94,7 +95,7 @@ def login_redirect():
|
||||
user = auth_context.get_user()
|
||||
session["user_id"] = user.id
|
||||
|
||||
return redirect(redirect_url())
|
||||
return redirect(redirect_after_login_url())
|
||||
|
||||
|
||||
@bp.route("/logout")
|
||||
|
@ -1,6 +1,6 @@
|
||||
from flask import Blueprint, request, session, redirect
|
||||
|
||||
from . import redirect_url
|
||||
from . import redirect_after_login_url
|
||||
from atst.domain.users import Users
|
||||
|
||||
bp = Blueprint("dev", __name__)
|
||||
@ -64,4 +64,4 @@ def login_dev():
|
||||
)
|
||||
session["user_id"] = user.id
|
||||
|
||||
return redirect(redirect_url())
|
||||
return redirect(redirect_after_login_url())
|
||||
|
Loading…
x
Reference in New Issue
Block a user