mirror of
https://github.com/System-End/cdn.git
synced 2026-04-19 16:18:17 +00:00
16 lines
316 B
Ruby
16 lines
316 B
Ruby
# frozen_string_literal: true
|
|
|
|
class APIKeyPolicy < ApplicationPolicy
|
|
def index? = true
|
|
def create? = true
|
|
|
|
def destroy?
|
|
user.is_admin? || record.user_id == user.id
|
|
end
|
|
|
|
class Scope < ApplicationPolicy::Scope
|
|
def resolve
|
|
user.is_admin? ? scope.all : scope.where(user: user)
|
|
end
|
|
end
|
|
end
|