Sha256: 1248f6d9f6e5399ff8546658d7669c0e51484a23873759b72e549c3207240c8a

Contents?: true

Size: 978 Bytes

Versions: 15

Compression:

Stored size: 978 Bytes

Contents

module Spree
  module Api
    module V2
      module Storefront
        class PasswordsController < ::Spree::Api::V2::BaseController
          include Spree::Core::ControllerHelpers::Store

          def create
            user = Spree.user_class.find_by(email: params[:user][:email])

            if user&.send_reset_password_instructions(current_store)
              head :ok
            else
              head :not_found
            end
          end

          def update
            user = Spree.user_class.reset_password_by_token(
              password: params[:user][:password],
              password_confirmation: params[:user][:password_confirmation],
              reset_password_token: params[:id]
            )

            if user.errors.empty?
              head :ok
            else
              render json: { error: user.errors.full_messages.to_sentence }, status: :unprocessable_entity
            end
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
spree_auth_devise-4.6.3 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.6.2 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.6.1 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.6.0 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.5.0 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.4.2 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.2.1 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.4.1 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.4.0 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.3.4 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.3.3 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.3.2 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.3.1 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.3.0 app/controllers/spree/api/v2/storefront/passwords_controller.rb
spree_auth_devise-4.2.0 app/controllers/spree/api/v2/storefront/passwords_controller.rb