send_password_reset_email: Add a flag to only email users who need it.

Emailing the password reset email to users who have already logged in
is not as useful.
This commit is contained in:
Alex Vandiver 2024-01-04 15:23:25 +00:00 committed by Tim Abbott
parent 6635f3ea12
commit 5b1387c9ba
2 changed files with 17 additions and 0 deletions

View File

@ -62,6 +62,13 @@ If you imported your organization into Zulip Cloud, simply e-mail
./manage.py send_password_reset_email -r <subdomain> --all-users
```
If you would like to only send emails to users who have not logged in yet,
you can use the following variant instead:
```
./manage.py send_password_reset_email -r <subdomain> --all-users --only-never-logged-in
```
{end_tabs}
### Manual password resets

View File

@ -17,6 +17,11 @@ class Command(ZulipBaseCommand):
@override
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument(
"--only-never-logged-in",
action="store_true",
help="Filter to only users which have not accepted the TOS.",
)
parser.add_argument(
"--entire-server", action="store_true", help="Send to every user on the server. "
)
@ -43,6 +48,11 @@ class Command(ZulipBaseCommand):
"You have to pass -u/--users or -a/--all-users or --entire-server."
)
raise error
if options["only_never_logged_in"]:
users = users.filter(tos_version=-1)
if not users.exists():
print("No matching users!")
self.send(users)