chore: Clean up report & knowledge base policies (#11234)
- Removes the portal_members table and all associated records - Updates policies to use custom roles with knowledge_base_manage permission - Updates controllers, models, and views to work without portal membership - Adds tests for the new permission model
This commit is contained in:
@@ -1,37 +1,31 @@
|
||||
class ArticlePolicy < ApplicationPolicy
|
||||
def index?
|
||||
@account_user.administrator? || @account.users.include?(@user)
|
||||
@account.users.include?(@user)
|
||||
end
|
||||
|
||||
def update?
|
||||
@account_user.administrator? || portal_member?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def show?
|
||||
@account_user.administrator? || portal_member?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def edit?
|
||||
@account_user.administrator? || portal_member?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def create?
|
||||
@account_user.administrator? || portal_member?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
@account_user.administrator? || portal_member?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def reorder?
|
||||
@account_user.administrator? || portal_member?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def portal_member?
|
||||
@record.first.portal.members.include?(@user)
|
||||
@account_user.administrator?
|
||||
end
|
||||
end
|
||||
|
||||
ArticlePolicy.prepend_mod_with('Enterprise::ArticlePolicy')
|
||||
ArticlePolicy.prepend_mod_with('ArticlePolicy')
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
class CategoryPolicy < ApplicationPolicy
|
||||
def index?
|
||||
@account_user.administrator? || @account.users.include?(@user)
|
||||
@account.users.include?(@user)
|
||||
end
|
||||
|
||||
def update?
|
||||
@account_user.administrator? || portal_member?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def show?
|
||||
@account_user.administrator? || portal_member?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def edit?
|
||||
@account_user.administrator? || portal_member?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def create?
|
||||
@account_user.administrator? || portal_member?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
@account_user.administrator? || portal_member?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def portal_member?
|
||||
@record.first.portal.members.include?(@user)
|
||||
@account_user.administrator?
|
||||
end
|
||||
end
|
||||
|
||||
CategoryPolicy.prepend_mod_with('Enterprise::CategoryPolicy')
|
||||
CategoryPolicy.prepend_mod_with('CategoryPolicy')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class PortalPolicy < ApplicationPolicy
|
||||
def index?
|
||||
@account_user.administrator? || @account.users.include?(@user)
|
||||
@account.users.include?(@user)
|
||||
end
|
||||
|
||||
def update?
|
||||
@@ -8,7 +8,7 @@ class PortalPolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def show?
|
||||
@account_user.administrator? || portal_member?
|
||||
@account.users.include?(@user)
|
||||
end
|
||||
|
||||
def edit?
|
||||
@@ -23,19 +23,9 @@ class PortalPolicy < ApplicationPolicy
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def add_members?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def logo?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def portal_member?
|
||||
@record.first.members.include?(@user)
|
||||
end
|
||||
end
|
||||
|
||||
PortalPolicy.prepend_mod_with('Enterprise::PortalPolicy')
|
||||
PortalPolicy.prepend_mod_with('PortalPolicy')
|
||||
|
||||
@@ -4,4 +4,4 @@ class ReportPolicy < ApplicationPolicy
|
||||
end
|
||||
end
|
||||
|
||||
ReportPolicy.prepend_mod_with('Enterprise::ReportPolicy')
|
||||
ReportPolicy.prepend_mod_with('ReportPolicy')
|
||||
|
||||
Reference in New Issue
Block a user