Ejemplo n.º 1
0
def register_page():
    title = "Register"

    if current_user.is_authenticated:
        return redirect(url_for('home_page'))

    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 registered!!!')

        return redirect(url_for('login_page'))

    return render_template('register.html', title=title, form=form)
Ejemplo n.º 2
0
 def test_password_hashing(self):
     u = User(username='******')
     u.set_password('cat')
     self.assertFalse(u.check_password('cheese'))
     self.assertTrue(u.check_password('cat'))