10
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/update_password.rb', line 10
def resolve(current_password: nil, **attrs)
if current_resource.blank?
raise_user_error(I18n.t('graphql_devise.not_authenticated'))
elsif current_resource.provider != 'email'
raise_user_error(
I18n.t('graphql_devise.passwords.password_not_required', provider: current_resource.provider.humanize)
)
end
if update_resource_password(current_password, attrs)
current_resource.allow_password_change = false if recoverable_enabled?
current_resource.save!
yield current_resource if block_given?
{ authenticatable: current_resource }
else
raise_user_error_list(
I18n.t('graphql_devise.passwords.update_password_error'),
errors: current_resource.errors.full_messages
)
end
end
|