mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
黑名单功能
This commit is contained in:
1 parent
55912b087d
commit
160b4482cc
11 files changed
+282
-158
No files matched your search
@@ -106,11 +106,12 @@ class DomainUserHandler extends ManageHandler {
|
||||
for (const role of roles) rudocs[role._id] = [];
|
||||
for (const udoc of udocs) {
|
||||
uids.push(udoc.uid);
|
||||
// TODO Improve here
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const ud = await user.getById(domainId, udoc.uid);
|
||||
const ud = user.getById(domainId, udoc.uid);
|
||||
rudocs[ud.role].push(ud);
|
||||
}
|
||||
const tasks = [];
|
||||
for (const key in rudocs) tasks.push(Promise.all(rudocs[key]));
|
||||
await Promise.all(tasks);
|
||||
const rolesSelect = roles.map((role) => [role._id, role._id]);
|
||||
const udict = await user.getList(domainId, uids);
|
||||
const path = [
|
||||
|
||||
@@ -97,7 +97,6 @@ class TrainingDetailHandler extends TrainingHandler {
|
||||
async get({ domainId, tid }) {
|
||||
const tdoc = await training.get(domainId, tid);
|
||||
const pids = training.getPids(tdoc);
|
||||
// TODO(twd2): check status, eg. test, hidden problem, ...
|
||||
const f = this.user.hasPerm(PERM_VIEW_PROBLEM_HIDDEN) ? {} : { hidden: false };
|
||||
const [udoc, pdict] = await Promise.all([
|
||||
user.getById(domainId, tdoc.owner),
|
||||
|
||||
@@ -8,7 +8,7 @@ const { PERM_LOGGEDIN } = require('../permission');
|
||||
const {
|
||||
UserAlreadyExistError, InvalidTokenError, VerifyPasswordError,
|
||||
UserNotFoundError, LoginError, SystemError,
|
||||
PermissionError,
|
||||
PermissionError, BlacklistedError,
|
||||
} = require('../error');
|
||||
|
||||
class UserLoginHandler extends Handler {
|
||||
@@ -23,8 +23,7 @@ class UserLoginHandler extends Handler {
|
||||
if (!udoc) throw new LoginError(uname);
|
||||
if (udoc) udoc.checkPassword(password);
|
||||
await user.setById(udoc._id, { loginat: new Date(), loginip: this.request.ip });
|
||||
udoc.salt = '';
|
||||
udoc.password = '';
|
||||
if (udoc.ban) throw new BlacklistedError(uname);
|
||||
this.session.uid = udoc._id;
|
||||
this.session.rememberme = rememberme;
|
||||
const referer = this.request.headers.referer || '/';
|
||||
@@ -63,7 +62,7 @@ class UserRegisterHandler extends Handler {
|
||||
);
|
||||
if (await system.get('smtp.user')) {
|
||||
const m = await this.renderHTML('user_register_mail.html', {
|
||||
url: `${await system.get('baseurl')}/register/${t[0]}`,
|
||||
url: `${await system.get('server.url')}/register/${t[0]}`,
|
||||
});
|
||||
await sendMail(mail, 'Sign Up', 'user_register_mail', m);
|
||||
this.response.template = 'user_register_mail_sent.html';
|
||||
|
||||
Reference in new issue
Block a user