Have recovery auto-verify the user

Fixes #1355
This commit is contained in:
Joseph Schorr 2016-04-08 13:38:16 -04:00
parent 3b5b5757e3
commit 1009362d26
2 changed files with 19 additions and 0 deletions

View file

@ -427,6 +427,10 @@ def validate_reset_code(code):
return None
user = code.user
if not user.verified:
user.verified = True
user.save()
code.delete_instance()
return user

View file

@ -106,6 +106,21 @@ class WebEndpointTestCase(EndpointTestCase):
code = model.user.create_reset_password_email_code(user.email)
self.getResponse('web.confirm_recovery', code=code.code, expected_code=302)
def test_confirm_recovery_verified(self):
# Create a valid code and try.
user = model.user.get_user('devtable')
user.verified = False
user.save()
code = model.user.create_reset_password_email_code(user.email)
self.getResponse('web.confirm_recovery', code=code.code, expected_code=302)
# Ensure the current user is the expected user and that they are verified.
user = model.user.get_user('devtable')
self.assertTrue(user.verified)
self.getResponse('web.receipt', expected_code=404) # Will 401 if no user.
def test_build_status_badge(self):
# Try for an invalid repository.
self.getResponse('web.build_status_badge', repository='foo/bar', expected_code=404)