class UserSession < Authlogic::Session::Base

  consecutive_failed_logins_limit 5
  # TODO think about removing timeout or make it optional with possibility to
  # set value, with hight default value smth like 40 minutes.
  self.logout_on_timeout = true unless Rails.env.development?
  before_validation :check_status

  def check_status
    if email
      user = User.where(:email => email).first
      if user
        errors.add(:base, I18n.t(:notice_account_is_blocked, :admin => user.verifable.try(:academy_unit).try(:name))) if user.blocked?
        errors.add(:base, I18n.t(:notice_account_is_not_active, :admin => user.verifable.try(:academy_unit).try(:name))) if user.not_active?
      else
        errors.add(:base, I18n.t(:notice_account_not_exists))
      end
    end
  end
end

class UserSession < Authlogic::Session::Base

  consecutive_failed_logins_limit 6
  failed_login_ban_for 3.hours
  # TODO think about removing timeout or make it optional with possibility to
  # set value, with hight default value smth like 40 minutes.
  self.logout_on_timeout = true unless Rails.env.development?
  before_validation :check_status

  def check_status
    if email
      user = User.where(:email => email).first
      if user
        errors.add(:base, I18n.t(:notice_account_is_blocked, :admin => user.verifable.try(:academy_unit).try(:name))) if user.blocked?
        errors.add(:base, I18n.t(:notice_account_is_not_active, :admin => user.verifable.try(:academy_unit).try(:name))) if user.not_active?
      else
        errors.add(:base, I18n.t(:notice_account_not_exists))
      end
    end
  end
end

Increase failed login count to 6
Increase failed login count to 6

Change-Id: I44d0b6a06e9f97b9cd3f51056af1c11c8fbcc47f
