Skip to content

Instantly share code, notes, and snippets.

@lucasmazza
Created March 13, 2013 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasmazza/0cdb09690450e6cd7e49 to your computer and use it in GitHub Desktop.
Save lucasmazza/0cdb09690450e6cd7e49 to your computer and use it in GitHub Desktop.
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