Sha256: 02933b015a640e077f6953791a2ff010e05e3810dbc67773a4958c0f49f0d62f

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module GraphqlDevise
  module Mutations
    class SendPasswordReset < Base
      argument :email,        String, required: true
      argument :redirect_url, String, required: true

      field :message, String, null: false

      def resolve(email:, redirect_url:)
        resource = find_resource(:email, get_case_insensitive_field(:email, email))

        if resource
          yield resource if block_given?

          resource.send_reset_password_instructions(
            email:         email,
            provider:      'email',
            redirect_url:  redirect_url,
            template_path: ['graphql_devise/mailer'],
            schema_url:    controller.full_url_without_params
          )

          if resource.errors.empty?
            { message: I18n.t('graphql_devise.passwords.send_instructions') }
          else
            raise_user_error_list(I18n.t('graphql_devise.invalid_resource'), errors: resource.errors.full_messages)
          end
        else
          raise_user_error(I18n.t('graphql_devise.user_not_found'))
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
graphql_devise-0.13.5 lib/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.13.4 lib/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.13.3 lib/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.13.2 lib/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.13.1 lib/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.13.0 lib/graphql_devise/mutations/send_password_reset.rb