Actually leave it to refresh on test, just make sure we dont overwrite

This commit is contained in:
shamoon
2024-10-05 11:52:04 -07:00
parent a4fd5fa7f5
commit 2b1087d837
6 changed files with 13 additions and 46 deletions

View File

@@ -80,8 +80,10 @@ class MailAccountTestView(GenericAPIView):
and account.expiration is not None
and account.expiration < timezone.now()
):
if refresh_oauth_token(account):
account.refresh_from_db()
if refresh_oauth_token(existing_account):
# User is not changing password and token needs to be refreshed
existing_account.refresh_from_db()
account.password = existing_account.password
else:
raise MailError("Unable to refresh oauth token")