Sha256: c8beb893a27c11bca5d6f0a9253d01c741f40e670086cec2e5c382a3ee9c8c73

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 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

    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

8 entries across 8 versions & 1 rubygems

Version Path
workarea-storefront-3.4.19 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.18 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.17 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.16 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.15 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.14 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.13 app/controllers/workarea/storefront/users/logins_controller.rb
workarea-storefront-3.4.12 app/controllers/workarea/storefront/users/logins_controller.rb