@ -41,7 +41,7 @@ class User {
$user = UserModel::search(['username' => $username]);
$success = false;
if ($user->exists() && $user->failed_login_attempt <= 2) {
if ($user->exists() && $user->loginAllowed()) {
$saltPassword = $user->salt . $password;
if (password_verify($saltPassword, $user->password)) {
$success = true;
@ -43,7 +43,7 @@ class LoginController extends PageController {
}
else {
$user = User::getUser('', $_POST['username']);
if ($user->exists() && $user->failed_login_attempt >= 5) {
if ($user->exists() && !$user->loginAllowed()) {
$this->setAlert('danger', 'User has been blocked.');
@ -3,5 +3,18 @@
namespace App\Model;
class UserModel extends Model {
protected $table = 'user';
//-------------------------------------//
public function loginAllowed(): bool
{
if (property_exists($this, 'failed_login_attempt') && $this->failed_login_attempt < 5) {
return true;
return false;