Sha256: 6c16e3b4eaab8960d90630284d6449fa257a91326bd54dcfbbaadd583744ff09

Contents?: true

Size: 898 Bytes

Versions: 6

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true

module GraphqlDevise
  module Mutations
    class ConfirmRegistrationWithToken < Base
      argument :confirmation_token, String, required: true

      field :credentials,
            Types::CredentialType,
            null:        true,
            description: 'Authentication credentials. Null unless user is signed in after confirmation.'

      def resolve(confirmation_token:)
        resource = resource_class.confirm_by_token(confirmation_token)

        if resource.errors.empty?
          yield resource if block_given?

          response_payload = { authenticatable: resource }

          response_payload[:credentials] = generate_auth_headers(resource) if resource.active_for_authentication?

          response_payload
        else
          raise_user_error(I18n.t('graphql_devise.confirmations.invalid_token'))
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
graphql_devise-1.4.0 lib/graphql_devise/mutations/confirm_registration_with_token.rb
graphql_devise-1.3.0 lib/graphql_devise/mutations/confirm_registration_with_token.rb
graphql_devise-1.2.0 lib/graphql_devise/mutations/confirm_registration_with_token.rb
graphql_devise-1.1.1 lib/graphql_devise/mutations/confirm_registration_with_token.rb
graphql_devise-1.1.0 lib/graphql_devise/mutations/confirm_registration_with_token.rb
graphql_devise-1.0.1 lib/graphql_devise/mutations/confirm_registration_with_token.rb