Sha256: 6a203be51b75024f1c116c1c60b3cc945f87070fd1c5a4e67b0a2c1584c7c20a

Contents?: true

Size: 1.44 KB

Versions: 9

Compression:

Stored size: 1.44 KB

Contents

class Spree::UserPasswordsController < Devise::PasswordsController
  helper 'spree/base', 'spree/store'

  include Spree::Core::ControllerHelpers::Auth
  include Spree::Core::ControllerHelpers::Common
  include Spree::Core::ControllerHelpers::Order
  include Spree::Core::ControllerHelpers::Store

  # Overridden due to bug in Devise.
  #   respond_with resource, location: new_session_path(resource_name)
  # is generating bad url /session/new.user
  #
  # overridden to:
  #   respond_with resource, location: spree.login_path
  #
  def create
    self.resource = resource_class.send_reset_password_instructions(params[resource_name])

    if resource.errors.empty?
      set_flash_message(:notice, :send_instructions) if is_navigational_format?
      respond_with resource, location: spree.login_path
    else
      respond_with_navigational(resource) { render :new }
    end
  end

  # Devise::PasswordsController allows for blank passwords.
  # Silly Devise::PasswordsController!
  # Fixes spree/spree#2190.
  def update
    if params[:spree_user][:password].blank?
      self.resource = resource_class.new
      resource.reset_password_token = params[:spree_user][:reset_password_token]
      set_flash_message(:error, :cannot_be_blank)
      render :edit
    else
      super
    end
  end

  protected

  def translation_scope
    'devise.user_passwords'
  end

  def new_session_path(resource_name)
    spree.send("new_#{resource_name}_session_path")
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
solidus_auth_devise-2.2.0 lib/controllers/frontend/spree/user_passwords_controller.rb
solidus_auth_devise_devise_token_auth-2.1.0.5 lib/controllers/frontend/spree/user_passwords_controller.rb
solidus_auth_devise_devise_token_auth-2.1.0.4 lib/controllers/frontend/spree/user_passwords_controller.rb
solidus_auth_devise_devise_token_auth-2.1.0.3 lib/controllers/frontend/spree/user_passwords_controller.rb
solidus_auth_devise_devise_token_auth-2.1.0.2 lib/controllers/frontend/spree/user_passwords_controller.rb
solidus_auth_devise_devise_token_auth-2.1.0.1 lib/controllers/frontend/spree/user_passwords_controller.rb
solidus_auth_devise_devise_token_auth-2.1.0 lib/controllers/frontend/spree/user_passwords_controller.rb
solidus_auth_devise-2.1.0 lib/controllers/frontend/spree/user_passwords_controller.rb
solidus_auth_devise-2.0.0 lib/controllers/frontend/spree/user_passwords_controller.rb