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

Python A Social Network with Flask Making Strong Users Bcryptkeeper

This makes no sense

What is going on

password_hashing.py
from flask.ext.bcrypt import generate_password_hash, check_password_hash

def set_password(user, password):
    user.password = generate_password_hash('test')
    user = user.password
    return user

1 Answer

2 mistakes: 1) You are passing in the parameter variable 'password', so pass that and not 'test' to generate_password_hash inside the function. 2) Omit the line "user = user.password". This passes:

from flask.ext.bcrypt import generate_password_hash, check_password_hash

def set_password(user, password):
    user.password = generate_password_hash(password)
    return user

Keep in mind, the function would then be used like this:

usr = 'Adrian'
pwd = 'test'

hashed_pwd_usr = set_password(usr, pwd)

I hope that helps. Happy coding!