Pundit authorization sitewide

This commit is contained in:
TheNeedful-DO 2023-12-05 05:27:51 +00:00
parent 5930a20efc
commit dcbeb8a72c

View File

@ -1,4 +1,5 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include Pundit::Authorization
# Prevent CSRF attacks by raising an exception. # Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead. # For APIs, you may want to use :null_session instead.
# protect_from_forgery with: :exception # protect_from_forgery with: :exception
@ -9,7 +10,6 @@ class ApplicationController < ActionController::Base
before_action :get_global_doodads before_action :get_global_doodads
if (Rails.env.development? || Rails.env.test?) if (Rails.env.development? || Rails.env.test?)
include Pundit::Authorization
after_action :verify_authorized, unless: -> { devise_controller? } after_action :verify_authorized, unless: -> { devise_controller? }
# after_action :verify_policy_scoped, only: :index # after_action :verify_policy_scoped, only: :index
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized