2022-11-21 12:10:04 +02:00
|
|
|
class ApplicationController < ActionController::Base
|
2022-12-20 17:29:05 +02:00
|
|
|
before_action :configure_permitted_parameters, if: :devise_controller?
|
2023-01-16 19:30:10 +02:00
|
|
|
|
2023-01-15 22:00:26 +02:00
|
|
|
include Pundit::Authorization
|
|
|
|
alias :current_user :current_member
|
2023-01-16 19:30:10 +02:00
|
|
|
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
|
2022-12-20 17:29:05 +02:00
|
|
|
|
2023-01-15 22:00:26 +02:00
|
|
|
protected
|
2022-12-20 17:29:05 +02:00
|
|
|
|
2023-01-15 22:00:26 +02:00
|
|
|
def configure_permitted_parameters
|
2023-06-03 19:45:14 +03:00
|
|
|
devise_parameter_sanitizer.permit(:sign_up, keys: [:name , :arriving , :leaving])
|
2023-01-15 22:00:26 +02:00
|
|
|
end
|
2023-01-16 19:30:10 +02:00
|
|
|
|
|
|
|
def user_not_authorized
|
|
|
|
flash[:alert] = "You are not authorized to perform this action."
|
|
|
|
redirect_back(fallback_location: root_path)
|
|
|
|
end
|
2022-11-21 12:10:04 +02:00
|
|
|
end
|