Browse Source

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 Petherbridge 5 years ago
parent
commit
da81ea21bc
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      rophako/modules/account.py

+ 7
- 1
rophako/modules/account.py View File

@@ -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

Loading…
Cancel
Save