mirror of
https://github.com/wassname/flask-security.git
synced 2026-07-09 00:20:10 +08:00
Fix #10
This commit is contained in:
@@ -76,12 +76,15 @@ def confirm_by_token(token):
|
||||
except UserNotFoundError:
|
||||
raise ConfirmationError('Invalid confirmation token')
|
||||
|
||||
if user.confirmed_at:
|
||||
raise ConfirmationError('Account has already been confirmed')
|
||||
|
||||
if confirmation_token_is_expired(user):
|
||||
raise TokenExpiredError(message='Confirmation token is expired',
|
||||
user=user)
|
||||
|
||||
user.confirmation_token = None
|
||||
user.confirmation_sent_at = None
|
||||
#user.confirmation_token = None
|
||||
#user.confirmation_sent_at = None
|
||||
user.confirmed_at = datetime.utcnow()
|
||||
|
||||
security.datastore._save_model(user)
|
||||
|
||||
@@ -186,7 +186,7 @@ class ConfirmableTests(SecurityTest):
|
||||
|
||||
self.client.get('/confirm?confirmation_token=' + token, follow_redirects=True)
|
||||
r = self.client.get('/confirm?confirmation_token=' + token, follow_redirects=True)
|
||||
self.assertIn('Invalid confirmation token', r.data)
|
||||
self.assertIn('Account has already been confirmed', r.data)
|
||||
|
||||
def test_unprovided_token_when_confirming_email(self):
|
||||
r = self.client.get('/confirm', follow_redirects=True)
|
||||
|
||||
Reference in New Issue
Block a user