Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding password reset email change fix #400

Merged
merged 14 commits into from
Sep 8, 2023
Merged
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# How to test?

# Trello
# Jira
5 changes: 2 additions & 3 deletions _infra/helm/party/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 2.4.30
version: 2.4.31

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 2.4.30

appVersion: 2.4.31
4 changes: 4 additions & 0 deletions ras_party/controllers/account_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,10 @@ def put_email_verification(token, tran, session):

if respondent:
update_verified_email_address(respondent, tran)
if respondent.password_verification_token:
# Reset password token fields in the database since they are linked to the old email
delete_respondent_password_verification_token(respondent.party_uuid, session)
reset_password_reset_counter(respondent.party_uuid, session)
else:
logger.info("Unable to find respondent by pending email")
raise NotFound("Unable to find user while checking email verification token")
Expand Down
10 changes: 9 additions & 1 deletion test/test_respondent_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def populate_with_respondent(self, session, respondent=None):
"mark_for_deletion": respondent["mark_for_deletion"],
"status": respondent.get("status") or RespondentStatus.CREATED,
"password_verification_token": self.generate_valid_token_from_email(respondent["emailAddress"]),
"password_reset_counter": 0,
"password_reset_counter": 1,
}
self.respondent = Respondent(**translated_party)
session.add(self.respondent)
Expand Down Expand Up @@ -1215,6 +1215,14 @@ def test_put_email_verification_uses_case_insensitive_email_query(self):
account_controller.put_email_verification(token)
query.assert_called_once_with("[email protected]", db.session())

def test_token_removed_on_email_update(self):
respondent = self.populate_with_respondent(respondent=self.mock_respondent_with_pending_email)
token = self.generate_valid_token_from_email(respondent.pending_email_address)
self.put_email_verification(token, 200)
respondent = respondents()[0]
self.assertIsNone(respondent.password_verification_token)
self.assertEqual(respondent.password_reset_counter, 0)

def test_post_respondent_with_payload_returns_200(self):
self.populate_with_business()
self.post_to_respondents(self.mock_respondent, 200)
Expand Down
Loading