Add url param to login form to control redirect
Site layouts that include a login form on every page can now include their relative URI (`request.path`) so the user can be redirected back to the same page after login.
This commit is contained in:
parent
afa783386b
commit
da81ea21bc
|
@ -34,6 +34,12 @@ def login():
|
||||||
session["uid"] = db["uid"]
|
session["uid"] = db["uid"]
|
||||||
session["name"] = db["name"]
|
session["name"] = db["name"]
|
||||||
session["role"] = db["role"]
|
session["role"] = db["role"]
|
||||||
|
|
||||||
|
# Redirect them to a local page?
|
||||||
|
url = request.form.get("url", "")
|
||||||
|
if url[0] == "/":
|
||||||
|
return redirect(url)
|
||||||
|
|
||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
else:
|
else:
|
||||||
flash("Authentication failed.")
|
flash("Authentication failed.")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user