Skip to content
Snippets Groups Projects

F convenient admin

Merged Alexander Schlemmer requested to merge f-convenient-admin into dev
1 unresolved thread
2 files
+ 24
3
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -116,13 +116,15 @@ def _promt_for_pw():
def do_create_user(args):
password = None
password = args.user_password
if args.ask_password is True:
password = _promt_for_pw()
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:
print(e.msg)
@@ -136,7 +138,10 @@ def do_deactivate_user(args):
def do_set_user_password(args):
password = _promt_for_pw()
if args.user_password is None:
password = _promt_for_pw()
else:
password = args.user_password
admin._update_user(name=args.user_name, password=password)
@@ -305,6 +310,8 @@ USAGE
subparser.set_defaults(call=do_create_user)
subparser.add_argument("-a", "--ask-password",
help="Prompt for a password.", action="store_true")
subparser.add_argument("-c", "--activate-user",
help="Activate the user after creation.", action="store_true")
subparser.add_argument(
metavar='USERNAME',
dest="user_name",
@@ -314,6 +321,12 @@ 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.")
@@ -331,12 +344,18 @@ USAGE
subparser = subparsers.add_parser(
"set_user_password",
help="Set a new password for a user. The password is not to be given on the command line for security reasons. You will be prompted for the password.")
help="Set a new password for a user. You will be prompted for the password if PASSWORD is not given.")
    • Please have a closer look at the logic: I think in this new implementation, giving a password is required. If it's not given on the command line, the program will ask for it. Is this the desired behaviour?

Please register or sign in to reply
subparser.set_defaults(call=do_set_user_password)
subparser.add_argument(
metavar='USERNAME',
dest="user_name",
help="The name of the user who's password is to be set.")
subparser.add_argument(
metavar='PASSWORD',
nargs="?",
dest="user_password",
default=None,
help="The user's new password.")
subparser = subparsers.add_parser(
"set_user_entity",
Loading