Fix login failed when username contains @ (#1894)

* Fix login failed when username contains @

* Update var/Widget/User.php

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Luffy
2025-11-20 17:17:31 +08:00
committed by GitHub
parent 570f982709
commit 15967ea059

View File

@@ -153,9 +153,16 @@ class User extends Users
/** 开始验证用户 **/
$user = $this->db->fetchRow($this->db->select()
->from('table.users')
->where((strpos($name, '@') ? 'mail' : 'name') . ' = ?', $name)
->where('name = ?', $name)
->limit(1));
if (empty($user) && strpos($name, '@') !== false) {
$user = $this->db->fetchRow($this->db->select()
->from('table.users')
->where('mail = ?', $name)
->limit(1));
}
if (empty($user)) {
return false;
}