diff options
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/bitmask/cli/mail.py | 19 | ||||
-rw-r--r-- | src/leap/bitmask/core/dispatcher.py | 8 | ||||
-rw-r--r-- | src/leap/bitmask/core/mail_services.py | 11 |
3 files changed, 27 insertions, 11 deletions
diff --git a/src/leap/bitmask/cli/mail.py b/src/leap/bitmask/cli/mail.py index 21b93c2..b6d6cd1 100644 --- a/src/leap/bitmask/cli/mail.py +++ b/src/leap/bitmask/cli/mail.py @@ -38,7 +38,7 @@ SUBCOMMANDS: '''.format(name=command.appname) - commands = ['enable', 'disable', 'get_token'] + commands = ['enable', 'disable'] def status(self, raw_args): parser = argparse.ArgumentParser( @@ -57,6 +57,23 @@ SUBCOMMANDS: return self._send(command.print_status) + def get_token(self, raw_args): + parser = argparse.ArgumentParser( + description='Bitmask email status', + prog='%s %s %s' % tuple(sys.argv[:3])) + parser.add_argument('uid', nargs='?', default=None, + help='uid to check the status of') + subargs = parser.parse_args(raw_args) + + uid = None + if subargs.uid: + uid = subargs.uid + else: + uid = self.cfg.get('bonafide', 'active', default=None) + self.data += ['get_token', uid] + + return self._send(command.default_dict_printer) + def mixnet_status(self, raw_args): parser = argparse.ArgumentParser( description='Bitmask mixnet status', diff --git a/src/leap/bitmask/core/dispatcher.py b/src/leap/bitmask/core/dispatcher.py index 519ec9d..1e364ec 100644 --- a/src/leap/bitmask/core/dispatcher.py +++ b/src/leap/bitmask/core/dispatcher.py @@ -264,8 +264,12 @@ class MailCmd(SubCommand): @register_method('dict') def do_GET_TOKEN(self, mail, *parts, **kw): - d = mail.get_token() - return d + try: + userid = parts[2] + except IndexError: + raise DispatchError( + 'wrong number of arguments: expected 1, got none') + return mail.get_token(userid) @register_method('dict') def do_MIXNET_STATUS(self, mail, *parts, **kw): diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index be84b3c..043f848 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -475,7 +475,6 @@ class StandardMailService(service.MultiService, HookableService): self._keymanager_sessions = {} self._sendmail_opts = {} self._service_tokens = {} - self._active_user = None self._mixnet_enabled = mixnet_enabled super(StandardMailService, self).__init__() self.initializeChildrenServices() @@ -508,7 +507,6 @@ class StandardMailService(service.MultiService, HookableService): def registerToken(token): self._service_tokens[userid] = token - self._active_user = userid return token incoming = self.getServiceNamed('incoming_mail') @@ -612,12 +610,9 @@ class StandardMailService(service.MultiService, HookableService): status = 'ok' return {'status': status} - def get_token(self): - active_user = self._active_user - if not active_user: - return defer.succeed({'user': None}) - token = self._service_tokens.get(active_user) - return defer.succeed({'user': active_user, 'token': token}) + def get_token(self, userid): + token = self._service_tokens.get(userid) + return {'user': userid, 'token': token} # access to containers |