Files
baffle-hub/app/policies/dsn_policy.rb
2025-11-09 20:58:13 +11:00

49 lines
752 B
Ruby

# frozen_string_literal: true
class DsnPolicy < ApplicationPolicy
def index?
current_user.present? && current_user.admin?
end
def show?
current_user.present? && current_user.admin?
end
def create?
current_user.present? && current_user.admin?
end
def new?
create?
end
def update?
current_user.present? && current_user.admin?
end
def edit?
update?
end
def destroy?
current_user.present? && current_user.admin?
end
def disable?
current_user.present? && current_user.admin?
end
def enable?
current_user.present? && current_user.admin?
end
class Scope < Scope
def resolve
if user&.admin?
scope.all
else
scope.none
end
end
end
end