Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Active users][Settings][Kebab] Add 'Reset password' option #215

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

carma12
Copy link
Collaborator

@carma12 carma12 commented Dec 14, 2023

The 'Reset password' option should take the new password values associated with the user account.

@carma12 carma12 force-pushed the kebab-reset-password-option branch 5 times, most recently from b6b5821 to 1ffdb6c Compare December 19, 2023 08:16
Copy link
Member

@pvoborni pvoborni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I've provided comments. The most important one is probably the "not visible error message". Remaining is more in an area of maintainability.

variantType="small"
modalPosition="top"
title="Reset password"
description="Reset the password for the selected user"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be improved later. But from UX perspective I'd rather see: Reset the password for user $UID. The reason is that in the "settings" page the user is not selected and it might be also a confirmation to the admin what user it applies to.

Alternatively, I'd remove the "description" altogether as it, in current form, doesn't add more info than what is already showed in the title.

CC @bdellasc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your point, I think is more useful to refer to the current user (especially when this is an operation that is not made in bulk).

I can either change the title to the one that you are proposing (Reset the password for user $UID) or leave it as it is from now until we can discuss this with @bdellasc . I personally prefer the latter because it can bring an interesting UX perspective :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both works for me. So we can go with your preferred.

@@ -700,6 +700,22 @@ export const api = createApi({
});
},
}),
changePassword: build.mutation<FindRPCResponse, any[]>({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of any[] looks as anti pattern to me, makes it harder to read, especially from usage perspective - where to use the call one must look at the implementation to know what the payload should look like.

I'd expect:

export interface PasswordChangePayload {
  uid: string;
  password: string;
}
changePassword: build.mutation<FindRPCResponse, PasswordChangePayload>({
      query: (pwPayload) => {
        const params = [
          [pwPayload.uid],
          {
            password: pwPayload.password,
            version: API_VERSION_BACKUP,
          },
        ];

        return getCommand({
          method: "passwd",
          params: params,
        });
      },
    }),

The question is whether the response should be FindRPCResponse. It moves the responsibility of parsing API result to the dialog instead of the rpc. E.g. it can return something like:

export interface OperationResult {
  success: boolean;
  // this would contain the success message obtain from API (result/result/summary) 
  // or the error  message (error/message).
  message: string; 
  error: ErrorResult; // this might not be needed
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have adapted the code to pass the PasswordChangePayload as a parameter (will push the changes in a minute).

About using the OperationResult interface instead of the FindRPCResponse - Is not a bad idea, but seems quite incomplete and redundant to me. From my point of view, the findRPCResponse can provide further information. about the status of the operation (failed/successful), the result received (sometimes multiple data), and even the number of returned items.

If we want to simplify the current FindRPCResponse I would add more elements to the interface. Something like:

export interface OperationResult {
  // If the operation failed or succeed
  success: boolean;
  // Result data if operation succeeds
  resultData: ObjectResult | undefined; 
  // Success/error messages (is it possible to receive multiple errors?)
  message: string;
}

This also brings another question (API-wise): when making an API call, is it possible to receive a valid result (E.g.: result.results.result is not undefined) and still get an error at the same time (result.error)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to "simplify" the Password dialog logic by getting data with well defined meaning instead of a general answer and thus needed to know what to look for in the answer. Or said differently, it`s about which component should have the message result parsing logic.

But the PR is ok even as it is.

@carma12 carma12 force-pushed the kebab-reset-password-option branch from 1ffdb6c to 7218994 Compare December 21, 2023 10:55
@carma12
Copy link
Collaborator Author

carma12 commented Dec 21, 2023

@pvoborni - I have already updated the code based on your feedback.

@pvoborni pvoborni self-assigned this Jan 5, 2024
@carma12 carma12 force-pushed the kebab-reset-password-option branch 3 times, most recently from 7e73bda to 099f79c Compare January 9, 2024 15:52
@carma12
Copy link
Collaborator Author

carma12 commented Jan 9, 2024

@pvoborni - The code has been updated based on your last comment.

@carma12 carma12 force-pushed the kebab-reset-password-option branch from 099f79c to bed4979 Compare January 10, 2024 08:54
The 'Reset password' option should
take the new password values
associated to the user account.

Signed-off-by: Carla Martinez <carlmart@redhat.com>
@carma12 carma12 force-pushed the kebab-reset-password-option branch from bed4979 to 59143ba Compare January 10, 2024 14:12
Copy link
Member

@pvoborni pvoborni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@carma12 carma12 merged commit bcaed53 into freeipa:main Jan 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants