diff --git a/public/include/classes/user.class.php b/public/include/classes/user.class.php index 62ff987a..3db25611 100644 --- a/public/include/classes/user.class.php +++ b/public/include/classes/user.class.php @@ -43,6 +43,9 @@ class User { public function getUserName($id) { return $this->getSingle($id, 'username', 'id'); } + public function getUserNameByEmail($email) { + return $this->getSingle($email, 'username', 'email', 's'); + } public function getUserId($username) { return $this->getSingle($username, 'id', 'username', 's'); } @@ -126,6 +129,13 @@ class User { $this->setErrorMessage("Invalid username or password."); return false; } + if (filter_var($username, FILTER_VALIDATE_EMAIL)) { + $this->debug->append("Username is an e-mail", 2); + if (!$username = $this->getUserNameByEmail($username)) { + $this->setErrorMessage("Invalid username or password."); + return false; + } + } if ($this->isLocked($this->getUserId($username))) { $this->setErrorMessage("Account is locked. Please contact site support."); return false;