Merge pull request #1357 from coreos-inc/verifyrecovery

Have recovery auto-verify the user
This commit is contained in:
josephschorr 2016-04-08 13:41:25 -04:00
commit 48c6449598
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)