Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
james white
78,399 PointsCode Challenge Bcryptkeeper, part 3
Link:
https://teamtreehouse.com/forum/code-challenge-bcryptkeeper-part-3
Challenge Task 3 of 3
Finally write a function named validate_password that takes a user and a password. It should return True if the provided password, when hashed, matches the user's password. Otherwise, return False.
Got through the first two parts of the challenge with:
from flask.ext.bcrypt import generate_password_hash
from flask.ext.bcrypt import check_password_hash
def set_password(User, string):
User.password=generate_password_hash(string)
return User
Then I tried this code for the third part of the challenge:
def validate_password(User, string):
if User.password==check_password_hash(string)
return True
else:
return False
..of course now it says:
Oops! It looks like Task 1 is no longer passing.
Probably some type of stupid error, but I don't know what to do to correct it..
Note: the 'Preview' button output hasn't been too helpful in giving error correction hints for this particular course.
2 Answers
David B Dinkins
71,472 PointsI just got stuck on this task too. You have to run the check_password_hash() method with both parameters in that conditional statement.
def validate_password(User, string):
if check_password_hash(User.password, string):
return True
else:
return False
Marc Martinez
12,909 PointsThanks for the help, but could you explain to me why you need both parameters?
james white
78,399 PointsTo Devin, Thanks for posting.
The Challenge link is at the top of my post (just underneath the title)
To David,
Thanks!
I marked your response as "Best Answer".
David B Dinkins
71,472 PointsNo problem, James :D
Devin Scheu
66,191 PointsDevin Scheu
66,191 PointsHey James, can i get the code challenge link to help you out?