-
-
Save anonymous/39c73c5f19c04210cd57fba9234ffa0c to your computer and use it in GitHub Desktop.
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