Files
leadchat/app/policies/article_policy.rb
Sojan Jose 58e78621ba chore: Custom Roles to manage permissions [ UI ] (#9865)
In admin settings, this Pr will add the UI for managing custom roles (
ref: https://github.com/chatwoot/chatwoot/pull/9995 ). It also handles
the routing logic changes to accommodate fine-tuned permissions.

---------

Co-authored-by: Pranav <pranavrajs@gmail.com>
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
Co-authored-by: iamsivin <iamsivin@gmail.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
2024-09-17 11:40:11 -07:00

38 lines
709 B
Ruby

class ArticlePolicy < ApplicationPolicy
def index?
@account_user.administrator? || @account.users.include?(@user)
end
def update?
@account_user.administrator? || portal_member?
end
def show?
@account_user.administrator? || portal_member?
end
def edit?
@account_user.administrator? || portal_member?
end
def create?
@account_user.administrator? || portal_member?
end
def destroy?
@account_user.administrator? || portal_member?
end
def reorder?
@account_user.administrator? || portal_member?
end
private
def portal_member?
@record.first.portal.members.include?(@user)
end
end
ArticlePolicy.prepend_mod_with('Enterprise::ArticlePolicy')