Sha256: 9fdb5a392d0bf5896666a3a21fdfd9bbb6c80b0008dae60525081aa62647254d

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

module GraphqlDevise
  module Mutations
    class ResendConfirmation < Base
      argument :email,        String, required: true, prepare: ->(email, _) { email.downcase }
      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?

          raise_user_error(I18n.t('graphql_devise.confirmations.already_confirmed')) if resource.confirmed?

          resource.send_confirmation_instructions(
            redirect_url:  redirect_url,
            template_path: ['graphql_devise/mailer']
          )

          {
            authenticatable: resource,
            message:       I18n.t('graphql_devise.confirmations.send_instructions', email: email)
          }
        else
          raise_user_error(I18n.t('graphql_devise.confirmations.user_not_found', email: email))
        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/resend_confirmation.rb
graphql_devise-0.11.4 lib/graphql_devise/mutations/resend_confirmation.rb
graphql_devise-0.11.3 lib/graphql_devise/mutations/resend_confirmation.rb
graphql_devise-0.11.2 lib/graphql_devise/mutations/resend_confirmation.rb
graphql_devise-0.11.1 lib/graphql_devise/mutations/resend_confirmation.rb