Example #1
0
def register():
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        new_user = User.create(username=form.username.data,
                        email=form.email.data,
                        password=form.password.data,
                        active=True)
        flash(_("Thank you for registering. You can now log in."), 'success')
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render('register.html', form=form)
Example #2
0
def load_user(id):
    return User.get_by_id(int(id))
Example #3
0
 def test_check_password(self):
     user = User.create(username="******", email="*****@*****.**",
                 password="******")
     assert user.check_password('foobarbaz123') is True
     assert user.check_password("barfoobaz") is False
Example #4
0
 def test_password_is_nullable(self):
     user = User(username='******', email='*****@*****.**')
     user.save()
     assert user.password is None
Example #5
0
 def test_created_at_defaults_to_datetime(self):
     user = User(username='******', email='*****@*****.**')
     user.save()
     assert bool(user.created_at)
     assert isinstance(user.created_at, dt.datetime)
Example #6
0
    def test_get_by_id(self):
        user = User('foo', '*****@*****.**')
        user.save()

        retrieved = User.get_by_id(user.id)
        assert retrieved == user