Class: GraphqlDevise::Mutations::ResendConfirmationWithToken

Inherits:
Base
  • Object
show all
Defined in:
lib/graphql_devise/mutations/resend_confirmation_with_token.rb

Instance Method Summary collapse

Instance Method Details

#resolve(email:, confirm_url:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/graphql_devise/mutations/resend_confirmation_with_token.rb', line 11

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