MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / execute

Method execute

keepercommander/commands/two_fa.py:267–292  ·  view source on GitHub ↗
(self, params, **kwargs)

Source from the content-addressed store, hash-verified

265 return TfaDeleteCommand.parser
266
267 def execute(self, params, **kwargs):
268 name = kwargs.get('name')
269 if not name:
270 raise CommandError('2fa delete', '"name" argument is required')
271 rs = api.communicate_rest(params, None, 'authentication/2fa_list', rs_type=APIRequest_pb2.TwoFactorListResponse)
272 channel = next((x for x in rs.channels if utils.base64_url_encode(x.channel_uid) == name), None)
273 if not channel:
274 l_name = name.casefold()
275 for x in rs.channels:
276 if l_name == x.channelName.casefold():
277 channel = x
278 break
279 if not channel:
280 raise CommandError('2fa delete', f'2FA channel "{name}" not found')
281
282 if not kwargs.get('force') is True:
283 channel_name = channel.channelName
284 if not channel_name:
285 channel_name = utils.base64_url_encode(channel.channel_uid)
286 answer = user_choice(f'Do you want to delete 2FA channel "{channel_name}"?', 'yn', 'n')
287 if answer not in ('y', 'Y'):
288 return
289 rq = APIRequest_pb2.TwoFactorDeleteRequest()
290 rq.channel_uid = channel.channel_uid
291 api.communicate_rest(params, rq, 'authentication/2fa_delete')
292 logging.info('2FA channel is deleted')

Callers

nothing calls this directly

Calls 4

user_choiceFunction · 0.85
CommandErrorClass · 0.70
getMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected