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)
def test_check_hashed_pw(self): user = User('BoogtehWoog', '*****@*****.**', 'Boogest1', 185, 180) value = user.check_password_hash('Boogest1') self.assertEqual(None, value)
def test_username_plain_validation(self): username = User.validate_username('BoogtehWoog') self.assertEqual('BoogtehWoog', username)
def test_email_bad_validation(self): email = User.validate_username('*****@*****.**') self.assertNotEqual('*****@*****.**', email)
def test_email_validation(self): email = User.validate_username('*****@*****.**') self.assertEqual('*****@*****.**', email)
def test_username_bad_length_validation(self): username = User.validate_username('Boog') self.assertNotEqual('Boog', username)
def test_username_bad_validation(self): username = User.validate_username('_BoogtehWoog') self.assertNotEqual('_BoogtehWoog', username)
def test_username_special_validation(self): username = User.validate_username('Boog!teh?Woog') self.assertEqual('Boog!teh?Woog', username)