16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/graphql_devise/mutations/register.rb', line 16
def resolve(confirm_url: nil, **attrs)
resource = build_resource(attrs.merge(provider: provider))
raise_user_error(I18n.t('graphql_devise.resource_build_failed')) if resource.blank?
redirect_url = confirm_url || DeviseTokenAuth.default_confirm_success_url
if confirmable_enabled? && redirect_url.blank?
raise_user_error(I18n.t('graphql_devise.registrations.missing_confirm_redirect_url'))
end
check_redirect_url_whitelist!(redirect_url)
resource.skip_confirmation_notification! if resource.respond_to?(:skip_confirmation_notification!)
if resource.save
yield resource if block_given?
unless resource.confirmed?
resource.send_confirmation_instructions(
redirect_url: redirect_url,
template_path: ['graphql_devise/mailer']
)
end
response_payload = { authenticatable: resource }
response_payload[:credentials] = (resource) if resource.active_for_authentication?
response_payload
else
resource.try(:clean_up_passwords)
raise_user_error_list(
I18n.t('graphql_devise.registration_failed'),
resource: resource
)
end
end
|