From 065a0e37205f637f3cf8fdadbc041a3fcccbaa39 Mon Sep 17 00:00:00 2001 From: "Amenya, Lee" Date: Sat, 1 Aug 2020 20:52:51 -0700 Subject: [PATCH] Enhancement: enable reporting multifactor authentication status(mfa) * enabled display of mfa and auth status * moved underline function to util --- sigsci_site_manager/site_manager.py | 9 +-------- sigsci_site_manager/user.py | 25 ++++++++++++++++--------- sigsci_site_manager/util.py | 9 ++++++++- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/sigsci_site_manager/site_manager.py b/sigsci_site_manager/site_manager.py index 4e7d456..c083511 100644 --- a/sigsci_site_manager/site_manager.py +++ b/sigsci_site_manager/site_manager.py @@ -9,7 +9,7 @@ from sigsci_site_manager.consts import CATEGORIES from sigsci_site_manager.deploy import deploy from sigsci_site_manager.merge import merge -from sigsci_site_manager.util import build_category_list +from sigsci_site_manager.util import build_category_list, underline from sigsci_site_manager.validate import validate from sigsci_site_manager.user import do_add_user, do_remove_user, do_list_membership, do_list_users from sigsci_site_manager.__version__ import __version__ @@ -35,13 +35,6 @@ def do_list(args): print('(%d sites)' % len(sites)) -def underline(text): - chars = "" - for char in text: - chars += "%c\u0332" % (char) - return chars - - def do_deploy(args): api = init_api(args.username, args.password, args.token, args.corp, args.dry_run) diff --git a/sigsci_site_manager/user.py b/sigsci_site_manager/user.py index d71ab31..5996ce6 100644 --- a/sigsci_site_manager/user.py +++ b/sigsci_site_manager/user.py @@ -1,7 +1,7 @@ import sys from sigsci_site_manager.api import init_api -from sigsci_site_manager.util import add_new_user +from sigsci_site_manager.util import add_new_user, underline def do_list_users(args): @@ -13,23 +13,30 @@ def do_list_users(args): else: users = api.get_corp_users() - cols = ['email', 'role', 'status', 'name'] - colFormat = "%45s %10s %10s %30s" + cols = ['email', 'role', 'status', 'mfaEnabled', 'authStatus', 'name'] + colFormat = "%45s %10s %10s %15s %15s %30s" + titleColFormat = "%50s %20s %15s %25s %25s %30s" if users: line_entries = [] if args.site_name: print('Site: %s' % args.site_name) - print(colFormat % (cols[0], 'site-' + cols[1], - cols[2], cols[3])) + print(titleColFormat % (underline(cols[0]), underline('site-' + cols[1]), + underline(cols[2]), underline(cols[3])), + underline(cols[4]), underline(cols[5])) for user in users['data']: line_entries.append(colFormat % (user['user'][cols[0]], user[cols[1]], - user['user'][cols[2]], user['user'][cols[3]])) + user['user'][cols[2]], + user['user'][cols[3]], + user['user'][cols[4]], + user['user'][cols[5]])) else: - print(colFormat % (cols[0], 'corp' + cols[1], - cols[2], cols[3])) + print(titleColFormat % (underline(cols[0]), underline('corp-' + cols[1]), + underline(cols[2]), underline(cols[3]), + underline(cols[4]), underline(cols[5]))) for user in users['data']: line_entries.append(colFormat % (user[cols[0]], user[cols[1]], - user[cols[2]], user[cols[3]])) + user[cols[2]], user[cols[3]], + user[cols[4]], user[cols[5]])) print_sorted_array(line_entries) diff --git a/sigsci_site_manager/util.py b/sigsci_site_manager/util.py index 884fa75..92a0be6 100644 --- a/sigsci_site_manager/util.py +++ b/sigsci_site_manager/util.py @@ -21,6 +21,13 @@ def filter_data(data, keys, optional_keys=[]): return ret +def underline(text): + chars = "" + for char in text: + chars += "%c\u0332" % (char) + return chars + + def _equal_single(a, b): # Single conditions have simple values for key in ['field', 'operator', 'value']: @@ -184,6 +191,6 @@ def add_new_user(api, email, role, api_user): finally: if add_user: api.add_corp_user(email, data) - + if update_user: api.update_corp_user(email, data)