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 Build a Social Network with Flask Making Strong Users Bcryptkeeper

Help please...

It might just be e not paying attention but I just don't understand the question. I even tryed def set_password() but yeaah...

utils.py
from flask.ext.bcrypt import generate_password_hash

from flask.ext.bcrypt import check_password_hash

1 Answer

Kourosh Raeen
Kourosh Raeen
23,733 Points

You need to define the set_password method, which takes a user and a password as the parameters. Then in the function pass the password to the generate_password_hash() method and assign the result to user.password. Finally, return the user:

from flask.ext.bcrypt import generate_password_hash
from flask.ext.bcrypt import check_password_hash

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

Thanks a lot mate, I appr it.