update model.user.create() api

This commit is contained in:
undefined committed 2020-07-22 18:54:18 +08:00
1 parent 162d93e5db
commit 37756c3724
14 files changed
+31 -57

No files matched your search

+2 -1
View File
@@ -172,7 +172,8 @@ class ProblemDetailHandler extends ProblemHandler {
@param('pid', Types.String, null, parsePid)
async _prepare(domainId: string, pid: number | string) {
this.response.template = 'problem_detail.html';
this.pdoc = await problem.get(domainId, pid, this.user._id, true);
this.pdoc = await problem.get(domainId, pid, this.user._id);
if (!this.pdoc) throw new ProblemNotFoundError(domainId, pid);
if (this.pdoc.hidden && this.pdoc.owner !== this.user._id) {
this.checkPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
}
+2 -2
View File
@@ -72,7 +72,7 @@ class RecordDetailHandler extends RecordHandler {
}
if (rdoc.type !== 'run') rdoc.stdout = rdoc.stderr = '';
const [pdoc, udoc] = await Promise.all([
problem.get(domainId, rdoc.pid, null, false),
problem.get(domainId, rdoc.pid, null),
user.getById(domainId, rdoc.uid),
]);
this.response.body = {
@@ -138,7 +138,7 @@ class RecordMainConnectionHandler extends RecordConnectionHandler {
// eslint-disable-next-line prefer-const
let [udoc, pdoc] = await Promise.all([
user.getById(this.domainId, rdoc.uid),
problem.get(this.domainId, rdoc.pid, null, false),
problem.get(this.domainId, rdoc.pid, null),
]);
if (pdoc && pdoc.hidden && !this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) pdoc = null;
else this.send({ html: await this.renderHTML('record_main_tr.html', { rdoc, udoc, pdoc }) });
+5 -6
View File
@@ -102,9 +102,7 @@ class UserRegisterWithCodeHandler extends Handler {
if (!mail) throw new InvalidTokenError(token.TYPE_REGISTRATION, code);
if (password !== verifyPassword) throw new VerifyPasswordError();
const uid = await system.inc('user');
await user.create({
uid, uname, password, mail, regip: this.request.ip,
});
await user.create(mail, uname, password, uid, this.request.ip);
await token.del(code, token.TYPE_REGISTRATION);
this.session.uid = uid;
this.response.redirect = this.url('homepage');
@@ -331,9 +329,10 @@ class OauthCallbackHandler extends Handler {
break;
}
}
const uid = await user.create({
mail: r.email, uname: username, password: String.random(32), regip: this.request.ip,
});
const uid = await user.create(
r.email, username, String.random(32),
undefined, this.request.ip,
);
const $set: any = {
oauth: args.type,
};