mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
better types & use attend instead of enroll
This commit is contained in:
1 parent
e7428c8f79
commit
3dd4c1c994
17 files changed
+141
-82
No files matched your search
@@ -159,7 +159,7 @@ class HomeSecurityHandler extends Handler {
|
||||
if (udoc) throw new UserAlreadyExistError(email);
|
||||
const [code] = await token.add(
|
||||
token.TYPE_CHANGEMAIL,
|
||||
await system.get('changemail_token_expire_seconds'),
|
||||
await system.get('changemail_token_expire_seconds') as number,
|
||||
{ uid: this.user._id, email },
|
||||
);
|
||||
const m = await this.renderHTML('user_changemail_mail.html', {
|
||||
|
||||
@@ -13,10 +13,10 @@ import {
|
||||
} from '../service/server';
|
||||
import { Tdoc } from '../interface';
|
||||
|
||||
async function _parseDagJson(domainId, dag) {
|
||||
async function _parseDagJson(domainId: string, _dag: string): Promise<Tdoc['dag']> {
|
||||
const parsed = [];
|
||||
try {
|
||||
dag = JSON.parse(dag);
|
||||
const dag = JSON.parse(_dag);
|
||||
assert(dag instanceof Array, 'dag must be an array');
|
||||
const ids = new Set(dag.map((s) => s._id));
|
||||
assert(dag.length === ids.size, '_id must be unique');
|
||||
@@ -177,16 +177,6 @@ class TrainingCreateHandler extends Handler {
|
||||
const pids = training.getPids(dag);
|
||||
assert(pids.length, new ValidationError('dag'));
|
||||
const pdocs = await problem.getMulti(domainId, { docId: { $in: pids } }).sort('_id', 1).toArray();
|
||||
const existPids = pdocs.map((pdoc) => pdoc.docId);
|
||||
const existPnames = pdocs.map((pdoc) => pdoc.pid);
|
||||
if (pids.length !== existPids.length) {
|
||||
for (const pid of pids) {
|
||||
assert(
|
||||
existPids.includes(pid) || existPnames.includes(pid),
|
||||
new ProblemNotFoundError(pid),
|
||||
);
|
||||
}
|
||||
}
|
||||
for (const pdoc of pdocs) {
|
||||
if (pdoc.hidden) this.checkPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||
}
|
||||
@@ -242,11 +232,10 @@ class TrainingEditHandler extends Handler {
|
||||
],
|
||||
}).sort('_id', 1).toArray();
|
||||
const existPids = pdocs.map((pdoc) => pdoc.docId);
|
||||
const existPnames = pdocs.map((pdoc) => pdoc.pid);
|
||||
if (pids.length !== existPids.length) {
|
||||
for (const pid in pids) {
|
||||
assert(
|
||||
existPids.includes(pid) || existPnames.includes(pid),
|
||||
existPids.includes(parseInt(pid, 10)),
|
||||
new ProblemNotFoundError(pid),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class UserRegisterHandler extends Handler {
|
||||
this.limitRate('send_mail', 3600, 30);
|
||||
const t = await token.add(
|
||||
token.TYPE_REGISTRATION,
|
||||
await system.get('registration_token_expire_seconds'),
|
||||
await system.get('registration_token_expire_seconds') as number,
|
||||
{ mail },
|
||||
);
|
||||
if (await system.get('smtp.user')) {
|
||||
@@ -118,7 +118,7 @@ class UserLostPassHandler extends Handler {
|
||||
if (!udoc) throw new UserNotFoundError(mail);
|
||||
const [tid] = await token.add(
|
||||
token.TYPE_LOSTPASS,
|
||||
await system.get('lostpass_token_expire_seconds'),
|
||||
await system.get('lostpass_token_expire_seconds') as number,
|
||||
{ uid: udoc._id },
|
||||
);
|
||||
const m = await this.renderHTML('user_lostpass_mail', { url: `lostpass/${tid}`, uname: udoc.uname });
|
||||
|
||||
Reference in new issue
Block a user