Sha256: b0a9caf0f66a61c4d4a328e86159a2316d8b6fb92a927bebee862b070d09b2e0

Contents?: true

Size: 944 Bytes

Versions: 5

Compression:

Stored size: 944 Bytes

Contents

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

      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']
          )

          if resource.errors.empty?
            { authenticatable: resource }
          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

5 entries across 5 versions & 1 rubygems

Version Path
graphql_devise-0.12.0 lib/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.11.4 lib/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.11.3 lib/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.11.2 lib/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.11.1 lib/graphql_devise/mutations/send_password_reset.rb