Пример #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('user.login'))
    return render_template('register.html', title='Register', form=form)
Пример #2
0
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)
Пример #3
0
 def test_password_hashing(self):
     u = User(username='******')
     u.set_password('test')
     self.assertFalse(u.check_password('dog'))
     self.assertTrue(u.check_password('test'))