cors_origins_policy.rb 441 Bytes
Newer Older
hellekin's avatar
hellekin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# frozen_string_literal: true

CorsOriginsPolicy = Struct.new(:user, :origin)

class CorsOriginsPolicy
  attr_reader :user, :origin

  def initialize(user, origin)
    @user = user
    @origin = origin
  end

  def index?
    true
  end

  def show?
    true
    # user.agent.origins.where(url: URI.parse(origin)).exists?
  end

  def create?
hellekin's avatar
hellekin committed
23
    user.maintainer?
hellekin's avatar
hellekin committed
24
  end
hellekin's avatar
hellekin committed
25
  alias update? create?
hellekin's avatar
hellekin committed
26

hellekin's avatar
hellekin committed
27 28
  def destroy?
    user.maintainer?
hellekin's avatar
hellekin committed
29 30
  end
end