Class: Spree::Api::V2::Storefront::ChangePasswordsController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/spree/api/v2/storefront/change_passwords_controller.rb

Instance Method Summary collapse

Instance Method Details

#change_password_paramsObject



22
23
24
25
26
27
# File 'app/controllers/spree/api/v2/storefront/change_passwords_controller.rb', line 22

def change_password_params
  result = params.permit(:current_password, :password, :password_confirmation)
  result[:user] = spree_current_user

  result.to_h
end

#resource_serializerObject



18
19
20
# File 'app/controllers/spree/api/v2/storefront/change_passwords_controller.rb', line 18

def resource_serializer
  Spree::V2::Storefront::UserSerializer
end

#updateObject



8
9
10
11
12
13
14
15
16
# File 'app/controllers/spree/api/v2/storefront/change_passwords_controller.rb', line 8

def update
  context = SpreeCmCommissioner::PasswordChanger.call(change_password_params)

  if context.success?
    render_serialized_payload { serialize_resource(context.user) }
  else
    render_error_payload(context.message)
  end
end