mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: allow login by email
This commit is contained in:
1 parent
149edf6f33
commit
3f2c6625a2
2 files changed
+3
-2
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.39.6",
|
||||
"version": "2.39.7",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -77,7 +77,8 @@ class UserLoginHandler extends Handler {
|
||||
@param('redirect', Types.String, true)
|
||||
async post(domainId: string, uname: string, password: string, rememberme = false, redirect = '') {
|
||||
if (!system.get('server.login')) throw new LoginError('Builtin login disabled.');
|
||||
const udoc = await user.getByUname(domainId, uname);
|
||||
let udoc = await user.getByEmail(domainId, uname);
|
||||
if (!udoc) udoc = await user.getByUname(domainId, uname);
|
||||
if (!udoc) throw new UserNotFoundError(uname);
|
||||
udoc.checkPassword(password);
|
||||
await user.setById(udoc._id, { loginat: new Date(), loginip: this.request.ip });
|
||||
|
||||
Reference in new issue
Block a user