core: allow login by email

This commit is contained in:
undefined committed 2021-09-26 23:17:49 +08:00
1 parent 149edf6f33
commit 3f2c6625a2
2 files changed
+3 -2

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.39.6",
"version": "2.39.7",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+2 -1
View File
@@ -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 });