Beispiel #1
0
    def test_generate_token(self):
        session = Client().session()
        user = User()
        session.add(user)
        session.flush()

        token = EmailVerificationToken.generate(user)
        eq_(len(token.token), 32)
Beispiel #2
0
def register():
    db_session = Client().session()
    user = User(
        email=request.form['email'],
        identifier=session['partial_user']['identifier'])
    db_session.add(user)
    db_session.flush()
    token = EmailVerificationToken.generate(user)
    send_verification_mail(
        user, url_for('verify_email', token=token.token, _external=True))
    session['user'] = {'email': user.email, 'identifier': user.identifier}
    return redirect(request.form['redirect_uri'])
Beispiel #3
0
    def test_verify_email(self):
        session = Client().session()
        user = User()
        session.add(user)
        session.flush()
        token = EmailVerificationToken.generate(user)

        response = self.app.get('/verify_email/{0}'.format(token.token))
        eq_(response.status_code, 200, response.data)
        assert 'Thanks!' in response.data, 'response was rude'

        del(user)
        user = session.query(User).one()
        assert user.email_verified_at, "email wasn't verified!"

        tokens = session.query(EmailVerificationToken).all()
        eq_(tokens, [])