def register(): if current_user.is_authenticated: return redirect(url_for('main.index')) form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash(_('Congratulations, you are now a registered user!')) return redirect(url_for('auth.login')) return render_template('auth/register.html', title=_('Register'), form=form)
def test_password_hashing(self): user = User(username='******') user.set_password('cat') self.assertTrue(user.check_password('cat')) self.assertFalse(user.check_password('dog'))