2016-10-16 00:29:57 +02:00
|
|
|
from argparse import ArgumentParser
|
2017-11-16 00:43:27 +01:00
|
|
|
from typing import Any
|
2013-04-02 18:00:12 +02:00
|
|
|
|
2017-08-07 21:18:19 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2017-11-16 00:43:27 +01:00
|
|
|
from zerver.lib.sessions import delete_all_deactivated_user_sessions, \
|
|
|
|
delete_all_user_sessions, delete_realm_user_sessions
|
2013-04-02 18:00:12 +02:00
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2017-08-07 21:18:19 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
2013-04-02 18:00:12 +02:00
|
|
|
help = "Log out all users."
|
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2016-10-16 00:29:57 +02:00
|
|
|
parser.add_argument('--deactivated-only',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Only logout all users who are deactivated")
|
2017-08-07 21:18:19 +02:00
|
|
|
self.add_realm_args(parser, help="Only logout all users in a particular realm")
|
2016-10-16 00:29:57 +02:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def handle(self, *args: Any, **options: Any) -> None:
|
2017-08-07 21:18:19 +02:00
|
|
|
realm = self.get_realm(options)
|
|
|
|
if realm:
|
2013-04-02 18:00:12 +02:00
|
|
|
delete_realm_user_sessions(realm)
|
2016-05-09 23:01:49 +02:00
|
|
|
elif options["deactivated_only"]:
|
|
|
|
delete_all_deactivated_user_sessions()
|
2013-04-02 18:00:12 +02:00
|
|
|
else:
|
|
|
|
delete_all_user_sessions()
|