def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(name=form.username.data, username=form.username.data.lower(), email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() flash(f'Account Created for {form.username.data}! You can now log in', 'info') return redirect(url_for('login')) return render_template('register.html', title="Register", form=form)
def password(self, plain_text_password): self.password_hash = bcrypt.generate_password_hash( plain_text_password).decode('utf-8')
def password(self, plain_text_password): # overwrite what is going to be store in password_hash self.password_hash = bcrypt.generate_password_hash( plain_text_password).decode('utf-8')
def password(self, password_to_hash): self.password_hash = bcrypt.generate_password_hash( password_to_hash).decode('utf-8')
def password(self, plain_text_password): # Assign hash_password field a hashed password generated from bcrypt instance self.hash_password = bcrypt.generate_password_hash( plain_text_password).decode('utf-8')