def test_expired_confirmation_token(self): u = Utente(password='******') db.session.add(u) db.session.commit() token = u.generate_confirmation_token(1) time.sleep(2) self.assertFalse(u.confirm(token))
def test_invalid_confirmation_token(self): u1 = Utente(password='******') u2 = Utente(password='******') db.session.add(u1) db.session.add(u2) db.session.commit() token = u1.generate_confirmation_token() self.assertFalse(u2.confirm(token))
def register(): form = RegistrationForm() if form.validate_on_submit(): user = Utente(email=form.email.data.lower(), username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() #Token e mail token = user.generate_confirmation_token() send_email(user.email, 'Conferma registrazione', '/email/confirm', user=user, token=token) flash('Una mail di conferma è stata inviata', 'success') return redirect(url_for('auth.login')) return render_template('register.html', form=form)
def test_valid_confirmation_token(self): u = Utente(password='******') db.session.add(u) db.session.commit() token = u.generate_confirmation_token() self.assertTrue(u.confirm(token))