-
Notifications
You must be signed in to change notification settings - Fork 356
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
Update the User data only if the validation passes #3345
Update the User data only if the validation passes #3345
Conversation
952a378
to
da82e1b
Compare
da82e1b
to
1161b36
Compare
@h-kataria - please review |
1161b36
to
62358a3
Compare
Checked commits lgalis/manageiq-ui-classic@46fc429~...62358a3 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
@@ -722,7 +722,7 @@ def rbac_edit_save_or_add(what, rbac_suffix = what) | |||
when :user | |||
record = @edit[:user_id] ? User.find_by(:id => @edit[:user_id]) : User.new | |||
validated = rbac_user_validate? | |||
rbac_user_set_record_vars(record) | |||
rbac_user_set_record_vars(record) if validated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgalis, change looks good, but i am curious why is invalid record being updated, shouldn't it skip save if record is not valid at https://github.com/lgalis/manageiq-ui-classic/blob/62358a3c6baef44122cb963fab2e576678aac7ba/app/controllers/ops_controller/ops_rbac.rb#L736
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rbac_user_set_record_vars updates the user's HABTM miq_groups link directly, without save being called for the User, this is how Rails' has_many and has_and_belongs_to_many associations work.
I also do not think there's a reason to set the record values if the UI validation is not successful. ( The validation for the Role doesn ot have this issue because the miq_user_role's features are not assigned directly).
looks good. |
Update the User data only if the validation passes (cherry picked from commit fbcf766) https://bugzilla.redhat.com/show_bug.cgi?id=1552873
Gaprindashvili backport details:
|
Update the User data only if the validation passes
Links
https://bugzilla.redhat.com/show_bug.cgi?id=1537601
Steps for Testing/QA