15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/graphql_devise/mutations/update_password_with_token.rb', line 15
def resolve(reset_password_token:, **attrs)
raise_user_error(I18n.t('graphql_devise.passwords.password_recovery_disabled')) unless recoverable_enabled?
resource = resource_class.with_reset_password_token(reset_password_token)
raise_user_error(I18n.t('graphql_devise.passwords.reset_token_not_found')) if resource.blank?
raise_user_error(I18n.t('graphql_devise.passwords.reset_token_expired')) unless resource.reset_password_period_valid?
if resource.update(attrs)
yield resource if block_given?
response_payload = { authenticatable: resource }
response_payload[:credentials] = (resource) if controller.signed_in?(resource_name)
response_payload
else
raise_user_error_list(
I18n.t('graphql_devise.passwords.update_password_error'),
resource: resource
)
end
end
|