2013-04-23 18:51:17 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
2016-10-16 00:29:57 +02:00
|
|
|
from argparse import ArgumentParser
|
2013-04-02 18:00:12 +02:00
|
|
|
|
2017-08-07 21:18:19 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2017-03-08 11:46:12 +01:00
|
|
|
from zerver.lib.sessions import delete_all_user_sessions, \
|
2016-05-09 23:01:49 +02:00
|
|
|
delete_realm_user_sessions, delete_all_deactivated_user_sessions
|
2013-04-02 18:00:12 +02: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."
|
|
|
|
|
2016-10-17 05:31:47 +02:00
|
|
|
def add_arguments(self, parser):
|
2016-10-16 00:29:57 +02:00
|
|
|
# type: (ArgumentParser) -> None
|
|
|
|
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
|
|
|
|
2013-04-02 18:00:12 +02:00
|
|
|
def handle(self, *args, **options):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (*Any, **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()
|