From fb1da439f95bfd7bdc7bf2092d8a411cd2522a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Wed, 4 Aug 2021 17:47:55 +0200 Subject: [PATCH] MAINT: change arguments of create_user create a mutually exclusive group instead of another optional argument --- src/caosdb/utils/caosdb_admin.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/caosdb/utils/caosdb_admin.py b/src/caosdb/utils/caosdb_admin.py index d926419d..9c18f896 100755 --- a/src/caosdb/utils/caosdb_admin.py +++ b/src/caosdb/utils/caosdb_admin.py @@ -123,6 +123,7 @@ def do_create_user(args): try: admin._insert_user(name=args.user_name, email=args.user_email, password=password) + if args.activate_user: do_activate_user(args) except HTTPClientError as e: @@ -306,12 +307,21 @@ USAGE # users (CRUD) subparser = subparsers.add_parser( "create_user", - help="Create a new user in caosdb's internal user database.") + help="Create a new user in caosdb's internal user database. You need " + " to activate the user before use.") subparser.set_defaults(call=do_create_user) - subparser.add_argument("-a", "--ask-password", - help="Prompt for a password.", action="store_true") + mg = subparser.add_mutually_exclusive_group() + mg.add_argument("-a", "--ask-password", + help="Prompt for a password.", action="store_true") + mg.add_argument( + "--password", + dest="user_password", + default=None, + help="Alternative way to provide the new user's password. Please " + "consider to use the more secure, interactive way (-a option).") subparser.add_argument("-c", "--activate-user", - help="Activate the user after creation.", action="store_true") + help="Activate the user after creation.", + action="store_true") subparser.add_argument( metavar='USERNAME', dest="user_name", @@ -321,12 +331,6 @@ USAGE nargs='?', dest="user_email", help="The email address of the new user.") - subparser.add_argument( - metavar='PASSWORD', - nargs="?", - dest="user_password", - default=None, - help="The new user's password. This is overwritten by the -a option.") subparser = subparsers.add_parser( "activate_user", help="(Re-)activate an inactive (but existing) user.") @@ -344,7 +348,8 @@ USAGE subparser = subparsers.add_parser( "set_user_password", - help="Set a new password for a user. You will be prompted for the password if PASSWORD is not given.") + help="Set a new password for a user. " + "By default, you will be prompted for the password.") subparser.set_defaults(call=do_set_user_password) subparser.add_argument( metavar='USERNAME', @@ -355,7 +360,8 @@ USAGE nargs="?", dest="user_password", default=None, - help="The user's new password.") + help="Alternative way to provide the user's new password. " + "The more secure (and default way) is to provide it interactively.") subparser = subparsers.add_parser( "set_user_entity", -- GitLab