mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
email: Convert accounts code to use delivery_email.
A key part of this is the new helper, get_user_by_delivery_email. Its verbose name is important for clarity; it should help avoid blind copy-pasting of get_user (which we'll also want to rename). Unfortunately, it requires detailed understanding of the context to figure out which one to use; each is used in about half of call sites. Another important note is that this PR doesn't migrate get_user calls in the tests except where not doing so would cause the tests to fail. This probably deserves a follow-up refactor to avoid bugs here.
This commit is contained in:
@@ -4,7 +4,7 @@ from typing import Any
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from zerver.models import UserProfile, get_realm, get_user
|
||||
from zerver.models import UserProfile, get_realm, get_user_by_delivery_email
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = """Sync your API key from ~/.zuliprc into your development instance"""
|
||||
@@ -21,7 +21,7 @@ class Command(BaseCommand):
|
||||
|
||||
try:
|
||||
realm = get_realm("zulip")
|
||||
user_profile = get_user(email, realm)
|
||||
user_profile = get_user_by_delivery_email(email, realm)
|
||||
user_profile.api_key = api_key
|
||||
user_profile.save(update_fields=["api_key"])
|
||||
except UserProfile.DoesNotExist:
|
||||
|
||||
Reference in New Issue
Block a user