X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fcli_commands%2Frbac.py;h=71fa12bec8712c62f06fd6f39c515491d6aec8d3;hb=c0420cf86aaed737f59666516dd9e4de5c5db16c;hp=d8f2068342e4efb38660b580e9c92b766ae7b4c9;hpb=fca1247748bdd66f7d461ad7f03be260ef1e9e18;p=osm%2Fosmclient.git diff --git a/osmclient/cli_commands/rbac.py b/osmclient/cli_commands/rbac.py index d8f2068..71fa12b 100755 --- a/osmclient/cli_commands/rbac.py +++ b/osmclient/cli_commands/rbac.py @@ -294,9 +294,9 @@ def project_update(ctx, project, name, quotas): "--projects", # prompt="Comma separate list of projects", multiple=True, - callback=lambda ctx, param, value: "".join(value).split(",") - if all(len(x) == 1 for x in value) - else value, + callback=lambda ctx, param, value: ( + "".join(value).split(",") if all(len(x) == 1 for x in value) else value + ), help="list of project ids that the user belongs to", ) @click.option( @@ -333,13 +333,6 @@ def user_create(ctx, username, password, projects, project_role_mappings, domain @click.command(name="user-update", short_help="updates user information") @click.argument("username") -@click.option( - "--password", - # prompt=True, - # hide_input=True, - # confirmation_prompt=True, - help="user password", -) @click.option("--set-username", "set_username", default=None, help="change username") @click.option( "--set-project", @@ -369,11 +362,14 @@ def user_create(ctx, username, password, projects, project_role_mappings, domain multiple=True, help="remove role(s) in a project. Can be used several times: 'project,role1[,role2,...]'", ) -@click.option("--change_password", "change_password", help="user's current password") +@click.option("--current-password", "current_password", help="user's current password") @click.option( - "--new_password", + "--new-password", "new_password", - help="user's new password to update in expiry condition", + # prompt=True, + # hide_input=True, + # confirmation_prompt=True, + help="new user password", ) @click.option( "--unlock", @@ -389,13 +385,12 @@ def user_create(ctx, username, password, projects, project_role_mappings, domain def user_update( ctx, username, - password, set_username, set_project, remove_project, add_project_role, remove_project_role, - change_password, + current_password, new_password, unlock, renew, @@ -404,35 +399,34 @@ def user_update( \b USERNAME: name of the user - PASSWORD: new password SET_USERNAME: new username SET_PROJECT: creating mappings for project/role(s) REMOVE_PROJECT: deleting mappings for project/role(s) ADD_PROJECT_ROLE: adding mappings for project/role(s) REMOVE_PROJECT_ROLE: removing mappings for project/role(s) - CHANGE_PASSWORD: user's current password to change - NEW_PASSWORD: user's new password to update in expiry condition + CURRENT_PASSWORD: user's current password to change + NEW_PASSWORD: user's new password to be updated UNLOCK: unlock user RENEW: renew user """ logger.debug("") user = {} - user["password"] = password user["username"] = set_username user["set-project"] = set_project user["remove-project"] = remove_project user["add-project-role"] = add_project_role user["remove-project-role"] = remove_project_role - user["change_password"] = change_password + user["current_password"] = current_password user["new_password"] = new_password user["unlock"] = unlock user["renew"] = renew utils.check_client_version(ctx.obj, ctx.command.name) - ctx.obj.user.update(username, user) - if not user.get("change_password"): + if not user.get("current_password"): + # In case the password is valid but the end user wants to update it ctx.obj.user.update(username, user) else: + # In case the password has expired (also applies in first login) ctx.obj.user.update(username, user, pwd_change=True) @@ -476,12 +470,14 @@ def user_list(ctx, filter): user["username"], user["_id"], user["_admin"]["user_status"].upper(), - time.strftime( - "%b-%d-%Y %X", - time.gmtime(user["_admin"]["account_expire_time"]), - ) - if not user["username"] == "admin" - else user["_admin"]["account_expire_time"], + ( + time.strftime( + "%b-%d-%Y %X", + time.gmtime(user["_admin"]["account_expire_time"]), + ) + if not user["username"] == "admin" + else user["_admin"]["account_expire_time"] + ), ] ) else: