Amend user-update operation to simplify options
[osm/osmclient.git] / osmclient / cli_commands / rbac.py
index 25e72d0..fcad963 100755 (executable)
@@ -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,34 +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)
-    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)