Beispiel #1
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(form.username.data, form.email.data, form.password.data)
        DBASE.session.add(user)
        DBASE.session.commit()
        flash(f'Account created for {user.username}.')
        login_user(user, remember=form.remember_me.data)
        return redirect(url_for('home'))
    return render_template('register.html', title='Register', form=form)
Beispiel #2
0
 def test_check_hashed_pw(self):
     user = User('BoogtehWoog', '*****@*****.**', 'Boogest1', 185,
                 180)
     value = user.check_password_hash('Boogest1')
     self.assertEqual(None, value)
Beispiel #3
0
 def test_username_plain_validation(self):
     username = User.validate_username('BoogtehWoog')
     self.assertEqual('BoogtehWoog', username)
Beispiel #4
0
 def test_email_bad_validation(self):
     email = User.validate_username('*****@*****.**')
     self.assertNotEqual('*****@*****.**', email)
Beispiel #5
0
 def test_email_validation(self):
     email = User.validate_username('*****@*****.**')
     self.assertEqual('*****@*****.**', email)
Beispiel #6
0
 def test_username_bad_length_validation(self):
     username = User.validate_username('Boog')
     self.assertNotEqual('Boog', username)
Beispiel #7
0
 def test_username_bad_validation(self):
     username = User.validate_username('_BoogtehWoog')
     self.assertNotEqual('_BoogtehWoog', username)
Beispiel #8
0
 def test_username_special_validation(self):
     username = User.validate_username('Boog!teh?Woog')
     self.assertEqual('Boog!teh?Woog', username)