Class: GraphqlDevise::Mutations::ConfirmRegistrationWithToken

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

Instance Method Summary collapse

Instance Method Details

#resolve(confirmation_token:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/graphql_devise/mutations/confirm_registration_with_token.rb', line 13

def resolve(confirmation_token:)
  resource = resource_class.confirm_by_token(confirmation_token)

  if resource.errors.empty?
    yield resource if block_given?

    response_payload = { authenticatable: resource }

    response_payload[:credentials] = generate_auth_headers(resource) if resource.active_for_authentication?

    response_payload
  else
    raise_user_error(I18n.t('graphql_devise.confirmations.invalid_token'))
  end
end