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

Implementing change password view #3294

Merged
merged 1 commit into from
May 10, 2018
Merged

Conversation

douglasgabriel
Copy link
Member

@douglasgabriel douglasgabriel commented Jan 22, 2018

This PR is able to:

  • Add a view to change password of a Physical Infra Provider

ems_physical_infra/show_list

screenshot from 2018-04-27 09-05-35

ems_physical_infra/change_password/${id}

image

image

image

After click in save button

image

The user can follow the change password request status in the tasks page

image

This PR depends on:

@douglasgabriel douglasgabriel changed the title Implementing change password view [WIP] Implementing change password view Jan 22, 2018
@miq-bot miq-bot added the wip label Jan 22, 2018
confirm_password = params[:confirm_password]

unless new_password.eql?(confirm_password)
add_flash(_("Confirmation password is not equal to new password"), :error)
Copy link
Contributor

Choose a reason for hiding this comment

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

@douglasgabriel This looks more like a fronend validation.
Noticed that the form is not in angular.
Please convert the form to angular so that you can address these form-level validations using angular.

Copy link
Contributor

Choose a reason for hiding this comment

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

Typically flash messages are displayed when you transition to a new screen.
In this particular case, you need to stay right inside the form and report the error to the user. As mentioned above this is a form validation and can be best handled with angular directives. What needs to happen here is - the "Confirmation password is not equal to new password" message needs to be displayed right under the password field in red

@ohadlevy
Copy link
Member

just wondering, do we need to show some indication of password strength? (e.g. weak, normal,, strong etc?)

@douglasgabriel
Copy link
Member Author

douglasgabriel commented Jan 30, 2018

Well, I think that this is a little bit more difficult to do, cause maybe all providers has its owns passwords rules. In some scenario, the MiQ UI can say that a password is strong, however the provider could reject this password because it break some password rule, what can make the user a bit confused. Don't you think? 🤔

My idea is to try change password in provider and if something goes wrong, catch the error message from provider and show to user

@douglasgabriel douglasgabriel changed the title [WIP] Implementing change password view Implementing change password view Feb 2, 2018
@miq-bot miq-bot removed the wip label Feb 2, 2018
@douglasgabriel douglasgabriel force-pushed the chg_pass branch 2 times, most recently from 7a5b1da to 1260f30 Compare April 11, 2018 20:12
@douglasgabriel
Copy link
Member Author

douglasgabriel commented May 2, 2018

@miq-bot remove_label pending core

# This method handle view objects of page
# +/ems_physical_infra/change_password/<id>+
def change_password
@record = model.find(params[:id])
Copy link
Contributor

Choose a reason for hiding this comment

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

params[:id] is exposed here.
Hence can you add an rbac check for this?
Thanks.

"redirect-url" => ems_physical_infra_path(@record),}

:javascript
miq_bootstrap('change-password-component');
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a new line here

@AparnaKarve
Copy link
Contributor

@douglasgabriel Tested this in the UI and this is looking really good.

A couple questions -

  • If the new password is the same as the current password, should we add a frontend validation to say that the new password needs to be different than the current password?
  • This might be a nit-pick, but do you think that the Confirm New password field should show only 1 validation message?
    For e.g. - It should be Required when there is no value in both New and Confirm
    And it should be only - Confirm password did not match when New is populated?

screen shot 2018-05-07 at 11 35 45 am

which actually brings me to my next question -
Are blank passwords supported for a Physical Infrastructure Provider?
If yes, then we may have to change the UX around this a bit.

@AparnaKarve
Copy link
Contributor

@douglasgabriel Can you also take a look at the codeclimate issues?
I believe the first one can be resolved easily with a simple refactor on the controller method.

@douglasgabriel douglasgabriel force-pushed the chg_pass branch 6 times, most recently from 2559274 to 02f247a Compare May 8, 2018 19:53
@douglasgabriel
Copy link
Member Author

Thanks @AparnaKarve for the suggestions here.

If the new password is the same as the current password, should we add a frontend validation to say that the new password needs to be different than the current password?

Great idea! I've put this validation, as well.

This might be a nit-pick, but do you think that the Confirm New password field should show only 1 validation message?

I also agree, this way is much better. Done!

Are blank passwords supported for a Physical Infrastructure Provider?

No, at least for the Lenovo Provider.

@douglasgabriel Can you also take a look at the codeclimate issues?

  • Cognitive complexity: I think this one is due to the conditionals statements used in field validation, IMO the code is already lean.

  • Method too long: the changePasswordFormController is a constructor method, so it make sense to be long, also, the others controllers are following this approach that defines all functions inside the constructor method.

  • Duplicated code: seems like some boilerplates

P.S. The Travis failures doesn't seems to be due this PR modifications 🤔

@AparnaKarve
Copy link
Contributor

@douglasgabriel You can address the Cognitive Complexity issue by making the functions - isFieldsEquals and modelInit exterior to the controller

In modelInit, I noticed that you don't really need name and action. Can you double-check that?
All references to vm.model.name can be changed to vm.recordName

@douglasgabriel douglasgabriel force-pushed the chg_pass branch 2 times, most recently from b47c85d to 0ff6ae2 Compare May 9, 2018 20:26
@miq-bot
Copy link
Member

miq-bot commented May 10, 2018

Checked commit douglasgabriel@3e26ed1 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
5 files checked, 0 offenses detected
Everything looks fine. 🍰

@douglasgabriel
Copy link
Member Author

Done @AparnaKarve :D

Copy link
Contributor

@AparnaKarve AparnaKarve left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks!

@dclarizio dclarizio merged commit a537177 into ManageIQ:master May 10, 2018
@dclarizio dclarizio added this to the Sprint 86 Ending May 21, 2018 milestone May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants