[IMPROVEMENT] Allow user login via E-Mail

This commit is contained in:
Sebastian Grewe 2013-09-18 07:33:57 +02:00
parent fbf2a86162
commit 5e64d43732

View File

@ -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;