core: allow banReason option

This commit is contained in:
undefined committed 2022-12-22 22:49:31 +08:00
1 parent 5c3e2d8571
commit be0423fe93
4 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -129,7 +129,7 @@ class UserLoginHandler extends Handler {
if (udoc._tfa && !verifyToken(udoc._tfa, tfa)) throw new InvalidTokenError('2FA');
udoc.checkPassword(password);
await user.setById(udoc._id, { loginat: new Date(), loginip: this.request.ip });
if (!udoc.hasPriv(PRIV.PRIV_USER_PROFILE)) throw new BlacklistedError(uname);
if (!udoc.hasPriv(PRIV.PRIV_USER_PROFILE)) throw new BlacklistedError(uname, udoc.banReason);
this.session.viewLang = '';
this.session.uid = udoc._id;
this.session.sudo = null;
@@ -471,5 +471,5 @@ export async function apply(ctx) {
ctx.Route('user_lostpass', '/lostpass', UserLostPassHandler);
ctx.Route('user_lostpass_with_code', '/lostpass/:code', UserLostPassWithCodeHandler);
ctx.Route('user_delete', '/user/delete', UserDeleteHandler, PRIV.PRIV_USER_PROFILE);
ctx.Route('user_detail', '/user/:uid', UserDetailHandler);
ctx.Route('user_detail', '/user/:uid(-?\\d+)', UserDetailHandler);
}