Sha256: 817dc21c966ea1222b17acbe761dc85c5fd36bab8aeaa678d20a6c202ebfe163

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module Osso
  module GraphQL
    module Mutations
      class ConfigureIdentityProvider < BaseMutation
        null false
        argument :id, ID, required: true
        argument :service, Types::IdentityProviderService, required: false
        argument :sso_url, String, required: false
        argument :sso_cert, String, required: false

        field :identity_provider, Types::IdentityProvider, null: false
        field :errors, [String], null: false

        def resolve(id:, **args)
          provider = Osso::Models::IdentityProvider.find(id)

          return response_data(identity_provider: provider) if provider.update(args)

          response_error(errors: provder.errors.messages)
        end

        def ready?(id:, **args)
          return true if context[:scope] == :admin

          domain = Osso::Models::IdentityProvider.find(id)&.domain

          return true if domain == context[:scope]

          raise ::GraphQL::ExecutionError, "This user lacks the scope to mutate records belonging to #{domain}"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
osso-0.0.3.8 lib/osso/graphql/mutations/configure_identity_provider.rb
osso-0.0.3.7 lib/osso/graphql/mutations/configure_identity_provider.rb