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 trialShawndee Boyd
6,002 PointsFinally write a function named validate_password that takes a user and a password. It should return True if the provided
I think that I have it logically but it says that Task 1 is not passing now. I would truly appreciate help! Thank you.
from flask.ext.bcrypt import generate_password_hash, check_password_hash
def set_password(User, a_string):
User.password = generate_password_hash('a_string')
return User
def validate_password(User, a_string):
if check_password_hash(User.password, a_string) == True
return True
else:
return False
3 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsFIrst up, I think you're missing a colon :
after the if
statement... you'll need that. You don't need the == True
though, since the check_password_hash
method will return a boolean (True
/False
) anyways.
Oh and for the call to the generate_password_hash method in your set_password
function, you're passing in an explicit string with the text a_string
, rather than the value of the parameter passed into the set_password
function... You should remove the single quotes from that.
michaelangelo owildeberry
18,173 Pointsdid it work?
=)
Shawndee Boyd
6,002 PointsThanks, Iain! That worked!!
Iain Simmons
Treehouse Moderator 32,305 PointsNo problem! :)