Sha256: 97f2fd0743e5b656b86de6a7ea9d7280365b10a303120cb18349849baa3fc1ad

Contents?: true

Size: 1.33 KB

Versions: 54

Compression:

Stored size: 1.33 KB

Contents

module Workarea
  class Storefront::Users::LoginsController < Storefront::ApplicationController
    before_action :ensure_not_locked, only: :create
    skip_before_action :require_password_changes, only: :destroy
    skip_before_action :verify_authenticity_token, only: :destroy

    def new
      @user = User.new
    end

    def create
      if user = User.find_for_login(params[:email], params[:password])
        login(user)

        login_service = Login.new(user, current_order).tap(&:perform)
        self.current_order = login_service.current_order

        flash[:success] = t('workarea.storefront.flash_messages.logged_in')
        redirect_back_or users_dashboard_path
      else
        flash[:error] = t('workarea.storefront.flash_messages.login_failure')
        @user = User.new
        render 'new', status: 422
      end
    end

    def destroy
      logout
      clear_current_order
      flash[:success] = t('workarea.storefront.flash_messages.logged_out')
      redirect_to login_path
    end

    private

    def users_dashboard_path
      current_user.admin? ? admin.root_path : users_account_path
    end

    def ensure_not_locked
      if User.login_locked?(params[:email])
        flash[:error] = t('workarea.storefront.flash_messages.account_locked')
        redirect_to(login_path)
        return false
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
workarea-storefront-3.5.27 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.5.26 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.45 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.5.25 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.5.23 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.44 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.5.22 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.43 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.5.21 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.42 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.5.20 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.41 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.5.19 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.40 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.5.18 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.39 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.5.17 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.38 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.5.16 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.37 app/controllers/workarea/storefront/users/logins_controller.rb