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:
Tim Abbott
2017-08-05 10:42:59 -07:00
parent 251bd3e577
commit dd49bec93c
2 changed files with 7 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ from zerver.lib.bugdown import (
url_embed_preview_enabled_for_realm
)
from zerver.lib.cache import (
delete_user_profile_caches,
to_dict_cache_key,
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):
# type: (UserProfile, Text) -> None
delete_user_profile_caches([user_profile])
user_profile.email = new_email
user_profile.save(update_fields=["email"])