Sha256: 2d71230c54cc29a988f40494e97e8d4c2db3ca937f0c133c4c039423bed3cea6

Contents?: true

Size: 1.33 KB

Versions: 13

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

module GraphqlDevise
  module Mutations
    class ResendConfirmationWithToken < Base
      argument :email,       String, required: true
      argument :confirm_url, String, required: true

      field :message, String, null: false

      def resolve(email:, confirm_url:)
        check_redirect_url_whitelist!(confirm_url)

        resource = find_confirmable_resource(email)

        if resource
          yield resource if block_given?

          if resource.confirmed? && !resource.pending_reconfirmation?
            raise_user_error(I18n.t('graphql_devise.confirmations.already_confirmed'))
          end

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

          { 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

      private

      def find_confirmable_resource(email)
        email_insensitive = get_case_insensitive_field(:email, email)
        resource = find_resource(:unconfirmed_email, email_insensitive) if resource_class.reconfirmable
        resource ||= find_resource(:email, email_insensitive)
        resource
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
graphql_devise-2.0.0 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-1.4.0 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-1.3.0 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-1.2.0 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-1.1.1 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-1.1.0 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-1.0.1 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-1.0.0 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-0.18.2 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-0.18.1 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-0.18.0 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-0.17.1 lib/graphql_devise/mutations/resend_confirmation_with_token.rb
graphql_devise-0.17.0 lib/graphql_devise/mutations/resend_confirmation_with_token.rb