Forked from
PortalMEC / portalmec
1813 commits behind the upstream repository.
-
Mauricio Giacomini Girardello authoredMauricio Giacomini Girardello authored
application_controller.rb 918 B
class ApplicationController < ActionController::API
include DeviseTokenAuth::Concerns::SetUserByToken
include Pundit
respond_to :json
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
# protect_from_forgery with: :null_session
before_action :configure_permitted_parameters, if: :devise_controller?
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
protected
def configure_permitted_parameters
registration_params = [:name, :email, :avatar, :password, :password_confirmation]
if params[:action] == 'update'
devise_parameter_sanitizer.for(:account_update) {
|u| u.permit(registration_params << :current_password)
}
elsif params[:action] == 'create'
devise_parameter_sanitizer.for(:sign_up) {
|u| u.permit(registration_params << :terms_of_service)
}
end
end
end