-
Notifications
You must be signed in to change notification settings - Fork 1
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
Disable Updating of User Emails #917
Conversation
- For the edited .erb files, `"disabled": true` has been set for the email fields section of forms (copies approach used in `app/views/org_admin/users/edit.html.erb`) - For added security, we are also removing `:email` from the .permit() update params of the corresponding controllers - Notes regarding changes to app/controllers/registrations_controller.rb: - Because `:email` was removed from the .permit() params, all of the `update_params[:email]`-related code needed to be addressed/removed (lines 161, 174, and 200) - The removal of `:email` from the update params allows for the removal of a lot of other code in the file. - The `if require_password` check in the `do_update` method is no longer needed. The comment on 197 stated `# user is changing email or password`. However, line 204-206 pointed out how this case is never actually reached for password changes (`def do_update_password` is executed instead). Since we are no longer allowing for the email to be changed either, it follows that `require_password` should always evaluate to false. - As result, we only need the code that corresponded to the `else` statement for `if require_password` (previously lines 225-228, now 185-188) - Also, because `require_password` is now always false, it follows that we can remove both the `require_password` arg from `def do_update` as well as the entirety of `def needs_password?`
These layout changes are being made to align with the changes in commit 74c960896 (i.e. setting `"disabled": true` to user.email in "Edit Profile")
Generated by 🚫 Danger |
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.
This is a great start! I just have a couple of question regarding updating the system user password.
Let me know if I am off the mark.
|
||
<div class="form-group col-xs-8"> | ||
<%= f.label(:email, _('Email'), class: 'control-label') %> | ||
<%= f.email_field(:email, class: "form-control", "aria-required": true, value: @user.email) %> | ||
<%= f.email_field(:email, class: "form-control", "aria-required": true, value: @user.email, "disabled": true) %> |
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.
I like how we are still showing the information here.
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.
Thanks for your responses! The only thing that is missing is the changelog entry.
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.
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.
LGTM!
Fixes #916
Changes proposed in this PR:
"disabled": true
withinf.email_field
for all forms (the same approach is already used inapp/views/org_admin/users/edit.html.erb
):email
from the .permit() update params of the controllers corresponding to the formsNotes regarding changes to
app/controllers/registrations_controller.rb
::email
was removed from the .permit() params, all of theupdate_params[:email]
- related code needed to be addressed/removed (lines 161, 174, and 200):email
fromupdate_params
enabled the removal of a lot of other code in the file.if require_password
check in thedo_update
method is no longer needed. The comment on 197 stated# user is changing email or password
. However, line 204-206 pointed out how this case is never actually reached for password changes (def do_update_password
is executed instead). Since we are no longer allowing for the email to be changed either, it follows thatrequire_password
should always evaluate to false.else
statement forif require_password
(previously lines 225-228, now 185-188)require_password
is now always false, it follows that we can remove both therequire_password
arg fromdef do_update
as well as the entirety ofdef needs_password?