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!

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

Python Build a Social Network with Flask Making Strong Users Bcryptkeeper

Shawndee Boyd
Shawndee Boyd
5,917 Points

Finally 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
        return False

3 Answers

FIrst 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.

did it work?


Shawndee Boyd
Shawndee Boyd
5,917 Points

Thanks, Iain! That worked!!

No problem! :)