Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

Commit

Permalink
🔧 Improved wrong login messages
Browse files Browse the repository at this point in the history
  • Loading branch information
anditv21 committed Oct 3, 2023
1 parent f7b3a18 commit c5135c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/app/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ public function loginUser($data)
Util::redirect("/index.php");
} else {
$this->loginfail($username);
return "Username/Password is wrong.";
if(!$this->doesthisuserexist($username))
{
return "No user with this name was found.";
}
return "Username/Password combination is wrong.";
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/app/models/UsersModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ protected function addrememberToken($token, $username)
$this->statement->execute([$username, $token, $ip, $browser, $os, $time, "none"]);
}

protected function loginfail($username)
protected function doesthisuserexist($username)
{
$this->prepare('SELECT * FROM `users` WHERE `username` = ?');
$this->statement->execute([$username]);
Expand All @@ -260,6 +260,14 @@ protected function loginfail($username)
if (!$row) {
return false;
}
else return true;
}

protected function loginfail($username)
{
if (!$this->doesthisuserexist($username)) {
return false;
}
else {
$this->prepare('UPDATE `users` SET `loginfails` = `loginfails` + 1 WHERE `username` = ?');
$this->statement->execute([$username]);
Expand Down

0 comments on commit c5135c5

Please sign in to comment.