Sha256: cba8e36a81fe4a7152062cb8e205aa9fc0794c769b0440d725e1e84203368d3f

Contents?: true

Size: 464 Bytes

Versions: 2

Compression:

Stored size: 464 Bytes

Contents

# frozen_string_literal: true

module Resolvers
  class EnterpriseAccount < GraphQL::Schema::Resolver
    type Types::EnterpriseAccount, null: false

    def resolve(args)
      return unless admin? || enterprise_authorized?(args[:domain])

      Osso::Models::EnterpriseAccount.find_by(domain: args[:domain])
    end

    def admin?
      context[:scope] == :admin
    end

    def enterprise_authorized?(domain)
      context[:scope] == domain
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
osso-0.0.3.2 lib/osso/graphql/resolvers/enterprise_account.rb
osso-0.0.3.1 lib/osso/graphql/resolvers/enterprise_account.rb