-
-
Save lucasmazza/0cdb09690450e6cd7e49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Devise | |
class ParametersSanitizer | |
attr_reader :params | |
def initialize(params) | |
@params = params | |
end | |
def registration_params(mapping) | |
params.require(mapping.name).permit(:email, :password, :password_confirmation) | |
end | |
def session_params(mapping) | |
params.require(mapping.name).permit(*authentication_keys + [:password]) | |
end | |
def unlock_params(mapping) | |
# I have no idea of what unlocks need. | |
params.require(mapping.name).permit([]) | |
end | |
def password_params(mapping) | |
params.require(mapping.name).permit(:email, :password, :password_confirmation, :reset_password_token) | |
end | |
protected | |
def authentication_keys | |
Devise.authentication_keys | |
end | |
end | |
end | |
class DeviseController | |
def parameters_sanitizer | |
DeviseController::ParametersSanitizer.new(params) | |
end | |
end | |
module Devise | |
class RegistrationsController | |
def resource_params | |
parameters_sanitizer.registration_params(devise_mapping) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment