Skip to content

Commit

Permalink
Merge pull request #82 from LUS24/master
Browse files Browse the repository at this point in the history
leospairani/cou-288-update-web-dev-course-code
  • Loading branch information
jslvtr authored Jul 10, 2023
2 parents 97004de + aae9573 commit 58a3e7e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ def signup():


@app.errorhandler(401)
def auth_error():
def auth_error(error):
return "Not authorized"
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ Instead, we need to use `pbkdf2_sha256.verify`:
password = request.form.get("password")

- if users.get(email) == password:
+ if pbkdf2_sha256.verify(password, users.get(email)):
session["email"] = email
return redirect(url_for("protected"))
+ if email in users.keys():
+ if pbkdf2_sha256.verify(password, users.get(email)):
session["email"] = email
return redirect(url_for("protected"))
else:
abort(401)
return render_template("login.html")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ def login():
email = request.form.get("email")
password = request.form.get("password")

if pbkdf2_sha256.verify(password, users.get(email)):
session["email"] = email
return redirect(url_for("protected"))
if email in users.keys():
if pbkdf2_sha256.verify(password, users.get(email)):
session["email"] = email
return redirect(url_for("protected"))
else:
abort(401)
return render_template("login.html")
Expand All @@ -61,5 +62,5 @@ def signup():


@app.errorhandler(401)
def auth_error():
def auth_error(error):
return "Not authorized"
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ def signup():


@app.errorhandler(401)
def auth_error():
def auth_error(error):
return "Not authorized"
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ def login():
email = request.form.get("email")
password = request.form.get("password")

if pbkdf2_sha256.verify(password, users.get(email)):
session["email"] = email
return redirect(url_for("protected"))
if email in users.keys():
if pbkdf2_sha256.verify(password, users.get(email)):
session["email"] = email
return redirect(url_for("protected"))
else:
abort(401)
return render_template("login.html")
Expand All @@ -72,5 +73,5 @@ def signup():


@app.errorhandler(401)
def auth_error():
def auth_error(error):
return "Not authorized"
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ def login():
email = request.form.get("email")
password = request.form.get("password")

if pbkdf2_sha256.verify(password, users.get(email)):
session["email"] = email
return redirect(url_for("protected"))
if email in users.keys():
if pbkdf2_sha256.verify(password, users.get(email)):
session["email"] = email
return redirect(url_for("protected"))
else:
abort(401)
return render_template("login.html")
Expand All @@ -61,5 +62,5 @@ def signup():


@app.errorhandler(401)
def auth_error():
def auth_error(error):
return "Not authorized"

0 comments on commit 58a3e7e

Please sign in to comment.