Maintenance: Bump pundit from 2.1.1 to 2.2.0

Bumps [pundit](https://github.com/varvet/pundit) from 2.1.1 to 2.2.0.
- [Release notes](https://github.com/varvet/pundit/releases)
- [Changelog](https://github.com/varvet/pundit/blob/main/CHANGELOG.md)
- [Commits](https://github.com/varvet/pundit/compare/v2.1.1...v2.2.0)
This commit is contained in:
Martin Gruner 2022-02-21 11:37:45 +01:00
parent 1183354321
commit 7a6539b262
4 changed files with 5 additions and 5 deletions

View file

@ -385,7 +385,7 @@ GEM
public_suffix (4.0.6) public_suffix (4.0.6)
puma (4.3.11) puma (4.3.11)
nio4r (~> 2.0) nio4r (~> 2.0)
pundit (2.1.1) pundit (2.2.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
pundit-matchers (1.7.0) pundit-matchers (1.7.0)
rspec-rails (>= 3.0.0) rspec-rails (>= 3.0.0)

View file

@ -2,7 +2,7 @@
module ApplicationController::Authorizes module ApplicationController::Authorizes
extend ActiveSupport::Concern extend ActiveSupport::Concern
include Pundit include Pundit::Authorization
private private

View file

@ -7,7 +7,7 @@ class KnowledgeBase::Public::CategoriesController < KnowledgeBase::Public::BaseC
@categories = categories_filter(@knowledge_base.categories.root) @categories = categories_filter(@knowledge_base.categories.root)
@object_locales = find_locales(@knowledge_base) @object_locales = find_locales(@knowledge_base)
authorize(@categories, policy_class: KnowledgeBase::Public::CategoryPolicy) authorize(@categories, policy_class: Controllers::KnowledgeBase::Public::CategoriesControllerPolicy)
rescue Pundit::NotAuthorizedError rescue Pundit::NotAuthorizedError
raise ActiveRecord::RecordNotFound raise ActiveRecord::RecordNotFound
end end

View file

@ -1,9 +1,9 @@
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class KnowledgeBase::Public::CategoryPolicy < ApplicationPolicy class Controllers::KnowledgeBase::Public::CategoriesControllerPolicy < ApplicationPolicy
def index? def index?
return true if user&.permissions?('knowledge_base.editor') return true if user&.permissions?('knowledge_base.editor')
return true if record.any? return true if record.present?
false false
end end