title: Not hashing password in Flask
body: <p>I don't know why the password is not hashing using Bcrypt. I think I am doing it right. I initilized Bcrypt correctly and I am using mongoengine. Everytime I look at the database it still shows the unencrypyed passwrod in text.</p>
  
  <p>users/models.py</p>
  
  <pre><code>from app import db, bcrypt
  class User(db.Document):
  
      username = db.StringField(required=True)
      first_name = db.StringField(required=True)
      last_name = db.StringField(required=True)
      email = db.EmailField(required=True)
      password = db.StringField(required=True)
  
      meta = {'collection': 'users'}
  
      @property
      def hash_password(self):
          return self.password
  
      @hash_password.setter
      def set_hash_password(self, password):
          self.password = bcrypt.generate_password_hash(password)
  
      def verify_password(self, password):
          return bcrypt.check_password_hash(self.password, password)
  </code></pre>
  
  <p>users/views.py</p>
  
  <pre><code>@userV.route('/signup', methods=['GET', 'POST'])
  def signup():
      form = SignUpForm()
  
      if form.validate_on_submit():
          user = User(
              first_name=form.first_name.data,
              last_name=form.last_name.data,
              username=form.username.data,
              email=form.email.data,
              password=form.password.data
          ).save()
  
          flash('You can now login')
          return render_template('user.html', variable="You can now login " + user.username)
  
      return render_template('signup.html', form=form)
  </code></pre>
  
  <p>users/auth/forms.py</p>
  
  <pre><code>class SignUpForm(Form):
      username = StringField('Username', validators=[
          InputRequired(message="Username is required"),
          Regexp('^[A-Za-z][A-Za-z0-9_]*[A-Za-z0-9]$', 0, 'Usernames must have only letters, numbers or underscores')
      ])
      first_name = StringField('First Name', validators=[
          InputRequired(message="First name is required")
      ])
      last_name = StringField('Last Name', validators=[
          InputRequired(message="Last name is required")
      ])
      email = StringField('Email Address', validators=[
          InputRequired(message="Email is required"),
          Email(message="This is not a valid email")
      ])
      password = PasswordField('Password', validators=[
          InputRequired(message="Password is required"),
          Length(min=6, message="The password is not long enough")
      ])
      accept_tos = BooleanField('Accept Terms of Service', validators=[
          InputRequired(message="You have to accept the Terms of Service in order to use this site")
      ])
      submit = SubmitField('Signup')
  
      def validate(self):
          if not Form.validate(self):
              return False
  
          if User.objects(username=self.username.data).first():
              raise ValidationError('Username already in use')
  
          if User.objects(email=self.email.data).first():
              raise ValidationError('Email already registered')
  
          return True
  </code></pre>
  
  <p>This is the outcome when I search mongodb shell. The password is not hashed.</p>
  
  <pre><code>{ "_id" : ObjectId("555df97deddd5543c360888a"), "username" : "FullMetal", "first_name" : "Edward", "last_name" : "Elric", "email" : "fullmetalalchemist@gmail.com", "password" : "equalexchange" }
  </code></pre>