2016-06-04 16:52:18 +02:00
|
|
|
from argparse import ArgumentParser
|
2017-05-25 00:29:59 +02:00
|
|
|
from typing import Any
|
|
|
|
|
2018-08-02 08:47:13 +02:00
|
|
|
from zerver.lib.actions import do_change_user_delivery_email
|
2017-07-07 20:35:31 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2013-02-10 22:45:25 +01:00
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2017-07-07 20:35:31 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
2015-08-21 02:10:41 +02:00
|
|
|
help = """Change the email address for a user."""
|
2013-02-10 22:45:25 +01:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2017-07-07 20:35:31 +02:00
|
|
|
self.add_realm_args(parser)
|
2020-09-02 21:24:05 +02:00
|
|
|
parser.add_argument('old_email', metavar='<old email>',
|
2015-08-21 02:10:41 +02:00
|
|
|
help='email address to change')
|
2020-09-02 21:24:05 +02:00
|
|
|
parser.add_argument('new_email', metavar='<new email>',
|
2015-08-21 02:10:41 +02:00
|
|
|
help='new email address')
|
2013-02-10 22:45:25 +01:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def handle(self, *args: Any, **options: str) -> None:
|
2015-08-21 02:10:41 +02:00
|
|
|
old_email = options['old_email']
|
|
|
|
new_email = options['new_email']
|
2017-07-07 20:35:31 +02:00
|
|
|
|
|
|
|
realm = self.get_realm(options)
|
|
|
|
user_profile = self.get_user(old_email, realm)
|
2013-02-10 22:45:25 +01:00
|
|
|
|
2018-08-02 08:47:13 +02:00
|
|
|
do_change_user_delivery_email(user_profile, new_email)
|