Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Build a Social Network with Flask Making Strong Users Bcryptkeeper

Can someone please help me with this task. I really don't know why its not passing.


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

def set_password(User, string1):
  User.password = generate_password_hash('string1')
  return User

2 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there, Roneshia Allen! The problem here is that you are hashing the password 'string1' instead of whatever the user sent in as their password which was then assigned to the variable string1.

Instead of:


You need:


Hope this helps! :sparkles:

It passed!!! thank you so much.

Jeff Muday
Jeff Muday
Treehouse Moderator 27,586 Points

Roneshia-- great work, you're very close to having it correct.

Jennifer perfectly identifies the string1 issue-- but, the Challenge automated grader is unusually specific about what the variables should be named too.

Changes to be made:

A. remove (or comment out) the import of set_password as you are defining it explicitly in the module.

B. make sure to use user rather than User

C. make sure to use password rather than string1

from flask.ext.bcrypt import generate_password_hash, check_password_hash
#from flask.ext.bcrypt import set_password

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

Keep up the good work on Flask! I use it in my daily work and really enjoy it.

Hey, it passed. Thank you so much.