Skip to content

Instantly share code, notes, and snippets.

@nfarah86
Created May 6, 2016 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfarah86/dbde054e26fe6d259ce3dd5ae25e5b66 to your computer and use it in GitHub Desktop.
Save nfarah86/dbde054e26fe6d259ce3dd5ae25e5b66 to your computer and use it in GitHub Desktop.
Processing Login Information
// omitted code
@app.route("/process_login", methods=["POST"])
def process_login():
#user should be in db, so .get
user_name = request.form.get("user_name")
password = request.form.get("password")
email = request.form.get("email")
#going to search db for user_name and password
user = db_session.query(User).filter_by(
user_name = user_name,
password = password).first()
if user:
#if true and user is in db
flash("Hurrah, system recognizes you!")
session["user_name"] = user.user_name
print user.user_name
session["user_id"] = user.id
print user.id
#going to access session
return redirect(url_for("personal_map"))
else:
#db doesn't recognize user
#redirect user to registration page
flash("Sorry, incorrect username or password!")
return render_template("register_user.html")
// omitted code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment