[IMPROVEMENT] Allow user login via E-Mail
This commit is contained in:
parent
fbf2a86162
commit
5e64d43732
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user