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

use Strong Parameters on User model user_params method #979

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lipedjow
Copy link

@lipedjow lipedjow commented Aug 9, 2022

This PR suggests 2 small improvements:

  • always return ActionParam object on UsersController user_params method (even if empty)
  • use Rails Strong Parameters to permit default user params instead of deleting params entries

this way we can easily override user_params method to add new custom fields for User model

let me know if it makes sense to add a configuration entry for changing default new User parameters, for example:
as default: Clearance.configuration.permit_user_parameters = [:email, :password]

we could customize it:
Clearance.configuration.permit_user_parameters = [:name, :email, :password]

and default permit call would looks like:
params.fetch(Clearance.configuration.user_parameter, {}).permit(*Clearance.configuration.permit_user_parameters)

@lipedjow
Copy link
Author

lipedjow commented Aug 9, 2022

ref #542

@lipedjow lipedjow requested a review from sej3506 as a code owner May 8, 2024 19:12
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.

None yet

2 participants