Sha256: 24cf851804f458db2b9746e9459afa9241eafef50160c12a76315aa2cca28c6b

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

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

  include Spree::Core::ControllerHelpers::Auth
  include Spree::Core::ControllerHelpers::Store

  helper 'spree/admin/navigation'
  layout 'spree/layouts/login'

  # 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], current_store)

    if resource.errors.empty?
      set_flash_message(:notice, :send_instructions) if is_navigational_format?
      respond_with resource, location: spree.admin_login_path
    else
      respond_with_navigational(resource) { render :new, status: :unprocessable_entity }
    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, status: :unprocessable_entity
    else
      super
    end
  end

  protected

  def translation_scope
    'devise.user_passwords'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_auth_devise-4.6.3 lib/controllers/backend/spree/admin/user_passwords_controller.rb
spree_auth_devise-4.6.2 lib/controllers/backend/spree/admin/user_passwords_controller.rb
spree_auth_devise-4.6.1 lib/controllers/backend/spree/admin/user_passwords_controller.rb
spree_auth_devise-4.6.0 lib/controllers/backend/spree/admin/user_passwords_controller.rb
spree_auth_devise-4.5.0 lib/controllers/backend/spree/admin/user_passwords_controller.rb