Example #1
0
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('login'))
    return render_template('register.html', title='Register', form=form)
Example #2
0
 def test_password_hashing(self):
     u=User(username='******')
     u.set_password('cat')
     self.assertFalse(u.check_password('dog'))
     self.assertTrue(u.check_password('cat'))