2018-05-23 10:32:04 +02:00
|
|
|
class ApplicationController < ActionController::Base
|
2018-05-29 13:09:42 +02:00
|
|
|
include Pundit
|
|
|
|
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
|
|
|
|
|
2018-05-24 23:40:23 +02:00
|
|
|
before_action :configure_devise_parameters, if: :devise_controller?
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def configure_devise_parameters
|
|
|
|
devise_parameter_sanitizer.permit(:sign_up, keys: [:tos_accepted])
|
|
|
|
devise_parameter_sanitizer.permit(:account_update, keys: [:notifications_enabled])
|
|
|
|
end
|
2018-05-29 13:09:42 +02:00
|
|
|
|
|
|
|
def user_not_authorized
|
|
|
|
flash[:alert] = I18n.t("user_not_authorized", scope: :flashes)
|
|
|
|
redirect_to(request.referrer || root_path)
|
|
|
|
end
|
2018-05-23 10:32:04 +02:00
|
|
|
end
|