mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
Fix changing email addresses back after email change.
We apparently were not correctly clearing the user_profile's email address from caches when changing email addresses, which meant that trying to look up the old email in the user_profile caches would still work. Fixes #6035.
This commit is contained in:
@@ -16,6 +16,7 @@ from zerver.lib.bugdown import (
|
|||||||
url_embed_preview_enabled_for_realm
|
url_embed_preview_enabled_for_realm
|
||||||
)
|
)
|
||||||
from zerver.lib.cache import (
|
from zerver.lib.cache import (
|
||||||
|
delete_user_profile_caches,
|
||||||
to_dict_cache_key,
|
to_dict_cache_key,
|
||||||
to_dict_cache_key_id,
|
to_dict_cache_key_id,
|
||||||
)
|
)
|
||||||
@@ -616,6 +617,8 @@ def do_deactivate_stream(stream, log=True):
|
|||||||
|
|
||||||
def do_change_user_email(user_profile, new_email):
|
def do_change_user_email(user_profile, new_email):
|
||||||
# type: (UserProfile, Text) -> None
|
# type: (UserProfile, Text) -> None
|
||||||
|
delete_user_profile_caches([user_profile])
|
||||||
|
|
||||||
user_profile.email = new_email
|
user_profile.email = new_email
|
||||||
user_profile.save(update_fields=["email"])
|
user_profile.save(update_fields=["email"])
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ class EmailChangeTestCase(ZulipTestCase):
|
|||||||
self.assert_in_success_response(["This confirms that the email address"],
|
self.assert_in_success_response(["This confirms that the email address"],
|
||||||
response)
|
response)
|
||||||
|
|
||||||
|
# Now confirm trying to change your email back doesn't throw an immediate error
|
||||||
|
result = self.client_patch(url, {"email": "hamlet@zulip.com"})
|
||||||
|
self.assert_in_success_response(['Check your email for a confirmation link.'], result)
|
||||||
|
|
||||||
def test_unauthorized_email_change(self):
|
def test_unauthorized_email_change(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
data = {'email': 'hamlet-new@zulip.com'}
|
data = {'email': 'hamlet-new@zulip.com'}
|
||||||
|
|||||||
Reference in New Issue
Block a user