Skip to content

Commit b0a286f

Browse files
committed
#45 Verify if the username is an e-mail and avoid big usernames
1 parent 1a7a297 commit b0a286f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

classes/BadpwFailedLoginsDAO.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ public function deleteObject(BadpwFailedLogins $badpwObj) : bool {
5858
* @return BadpwFailedLogins object Object matching the username
5959
*/
6060
public function getByUsername(string $username) : ?BadpwFailedLogins {
61+
// Verify if the username is an email
62+
if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
63+
$user = Repo::user()->getByEmail($username);
64+
if (!$user) {
65+
return null;
66+
}
67+
$username = $user->getData('userName');
68+
} elseif (strlen($username) > 32) { // Invalid username length
69+
return null;
70+
}
71+
6172
$result = $this->retrieve('
6273
SELECT *
6374
FROM badpw_failedlogins

0 commit comments

Comments
 (0)