Skip to content

Commit d59b766

Browse files
authored
leospairani/cou-288-update-web-dev-course-code
Added a line to check if email exists and added the error as a parameter to the error handler.
1 parent 97004de commit d59b766

File tree

1 file changed

+5
-4
lines changed
  • curriculum/section13/lectures/05_login_required_decorator/end/app

1 file changed

+5
-4
lines changed

curriculum/section13/lectures/05_login_required_decorator/end/app/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ def login():
4747
email = request.form.get("email")
4848
password = request.form.get("password")
4949

50-
if pbkdf2_sha256.verify(password, users.get(email)):
51-
session["email"] = email
52-
return redirect(url_for("protected"))
50+
if email in users.keys():
51+
if pbkdf2_sha256.verify(password, users.get(email)):
52+
session["email"] = email
53+
return redirect(url_for("protected"))
5354
else:
5455
abort(401)
5556
return render_template("login.html")
@@ -72,5 +73,5 @@ def signup():
7273

7374

7475
@app.errorhandler(401)
75-
def auth_error():
76+
def auth_error(error):
7677
return "Not authorized"

0 commit comments

Comments
 (0)