def register(): if current_user.is_authenticated: return redirect(url_for('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('user.login')) return render_template('register.html', title='Register', form=form)
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('You Signed Up succesfully. Now you can login to our service.') return redirect(url_for('auth.login')) return render_template('auth/register.html', form=form)
def test_password_hashing(self): u = User(username='******') u.set_password('test') self.assertFalse(u.check_password('dog')) self.assertTrue(u.check_password('test'))