Sha256: e990a381c87d9044ec9f508f622f5b1674f510ebe550bab35c17f94e1ea0e3d3

Contents?: true

Size: 956 Bytes

Versions: 6

Compression:

Stored size: 956 Bytes

Contents

module GraphqlDevise
  module Mutations
    class SendPasswordReset < Base
      argument :email,        String, required: true, prepare: ->(email, _) { email.downcase }
      argument :redirect_url, String, required: true

      def resolve(email:, redirect_url:)
        resource = controller.find_resource(:uid, 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?
            { authenticable: 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

6 entries across 6 versions & 1 rubygems

Version Path
graphql_devise-0.7.0 app/graphql/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.6.0 app/graphql/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.5.0 app/graphql/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.4.1 app/graphql/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.4.0 app/graphql/graphql_devise/mutations/send_password_reset.rb
graphql_devise-0.3.0 app/graphql/graphql_devise/mutations/send_password_reset.rb