/application.py Secret
Created
February 21, 2017 17:48
Star
You must be signed in to star a gist
application.py - shared from CS50 IDE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# query database for username | |
rows = db.execute("SELECT * FROM users WHERE username = :username", username=request.form.get("username")) | |
# ensure password is correct | |
if len(rows) != 1 or not pwd_context.verify(request.form.get("password"), rows[0]["hash"]): | |
return apology("invalid username and/or password") | |
db.execute("INSERT INTO users (username, password) VALUES(:name, :password)", name=request.form["username"], \ | |
password=request.form["hash"]) | |
# remember which user has logged in | |
session["user_id"] = rows[0]["id"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment