Files
redmine/app/controllers/concerns/authorization_concern.rb
Roman Vaníček bbe840cd8b Squashed 'plugins/redmine_hourglass/' content from commit ec937a4
git-subtree-dir: plugins/redmine_hourglass
git-subtree-split: ec937a4ed4717e358207dd3857fac248b9e625e9
2023-03-23 12:49:36 +01:00

31 lines
571 B
Ruby

module AuthorizationConcern
extend ActiveSupport::Concern
included do
include Pundit
rescue_from(Pundit::NotAuthorizedError) do |e|
render_403 message: e.policy.message, no_halt: true
end
def pundit_user
User.current
end
def authorize(record, query = nil)
super
record
end
def authorize_update(record, params)
authorize record
record.transaction do
record.with_before_save proc { authorize record } do
record.update params
end
end
record
end
end
end