Want everyone on your software team to learn this? Free 14-day trial.

Train my team
Trust Boundaries
Python
@app.post("/login")
def do_login():
  """Attempt to verify the username and password supplied by this user."""
  username = request.form["username"]
  password = request.form["password"]

  user = find_user_with_password(username, password)

  if not user:
    flash("Invalid credentials", "error")
    return redirect("/login")

  # Don't write untrusted content to the session until is has been verified.
  session["username"] = username

  return redirect("/timeline")