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.
pull/2/head
Noah 2014-05-09 19:29:49 +00:00
джерело afa783386b
коміт da81ea21bc
1 змінених файлів з 7 додано та 1 видалено

@ -34,6 +34,12 @@ def login():
session["uid"] = db["uid"]
session["name"] = db["name"]
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"))
else:
flash("Authentication failed.")
@ -126,4 +132,4 @@ def validate_create_form(username, pw1=None, pw2=None, skip_passwd=False):
if len(errors):
return errors
else:
return None
return None