mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 02:24:20 +00:00
Add email confirmation for nuew users
This commit is contained in:
parent
8c121a63de
commit
3b6c9f22dd
8
app/templates/auth/email/confirm.html.j2
Normal file
8
app/templates/auth/email/confirm.html.j2
Normal file
@ -0,0 +1,8 @@
|
||||
<p>Dear {{ user.username }},</p>
|
||||
<p>Welcome to <b>Opaque</b>!</p>
|
||||
<p>To confirm your account please <a href="{{ url_for('auth.confirm', token=token, _external=True) }}">click here</a>.</p>
|
||||
<p>Alternatively, you can paste the following link in your browser's address bar:</p>
|
||||
<p>{{ url_for('auth.confirm', token=token, _external=True) }}</p>
|
||||
<p>Sincerely,</p>
|
||||
<p>The Opaque Team</p>
|
||||
<p><small>Note: replies to this email address are not monitored.</small></p>
|
11
app/templates/auth/email/confirm.txt.j2
Normal file
11
app/templates/auth/email/confirm.txt.j2
Normal file
@ -0,0 +1,11 @@
|
||||
Dear {{ user.username }},
|
||||
|
||||
Welcome to Opaque!
|
||||
|
||||
To confirm your account please click on the following link:
|
||||
{{ url_for('auth.confirm', token=token, _external=True) }}
|
||||
|
||||
Sincerely,
|
||||
The Opaque Team
|
||||
|
||||
Note: replies to this email address are not monitored.
|
@ -1,5 +1,7 @@
|
||||
import unittest
|
||||
import time
|
||||
from app.models import User
|
||||
from app import db
|
||||
|
||||
|
||||
class UserModelTestCase(unittest.TestCase):
|
||||
@ -21,3 +23,27 @@ class UserModelTestCase(unittest.TestCase):
|
||||
u = User(password='cat')
|
||||
u2 = User(password='cat')
|
||||
self.assertTrue(u.password_hash != u2.password_hash)
|
||||
|
||||
def test_valid_confirmation_token(self):
|
||||
u = User(password='cat')
|
||||
db.session.add(u)
|
||||
db.session.commit()
|
||||
token = u.generate_confirmation_token()
|
||||
self.assertTrue(u.confirm(token))
|
||||
|
||||
def test_invalid_confirmation_token(self):
|
||||
u1 = User(password='cat')
|
||||
u2 = User(password='dog')
|
||||
db.session.add(u1)
|
||||
db.session.add(u2)
|
||||
db.session.commit()
|
||||
token = u1.generate_confirmation_token()
|
||||
self.assertFalse(u2.confirm(token))
|
||||
|
||||
def test_expired_confirmation_token(self):
|
||||
u = User(password='cat')
|
||||
db.session.add(u)
|
||||
db.session.commit()
|
||||
token = u.generate_confirmation_token(1)
|
||||
time.sleep(2)
|
||||
self.assertFalse(u.confirm(token))
|
||||
|
Loading…
Reference in New Issue
Block a user