core: 添加登录域名记录

This commit is contained in:
undefined committed 2021-01-25 13:15:31 +08:00
1 parent 3c4256be84
commit 66639b14de
4 files changed
+17 -36

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.17.0", "version": "2.17.1",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
-1
View File
@@ -281,7 +281,6 @@ export class ProblemPretestHandler extends ProblemDetailHandler {
@param('input', Types.String, true) @param('input', Types.String, true)
async post(domainId: string, lang: string, code: string, input: string = '') { async post(domainId: string, lang: string, code: string, input: string = '') {
this.limitRate('add_record', 3600, 100); this.limitRate('add_record', 3600, 100);
// TODO parseConfig
const rid = await record.add( const rid = await record.add(
domainId, this.pdoc.docId, this.user._id, domainId, this.pdoc.docId, this.user._id,
lang, code, true, lang, code, true,
-1
View File
@@ -116,7 +116,6 @@ export async function calcLevel(domainId: string, report: Function) {
bulk.find(query).update({ $set: { level: levels[i][0] } }); bulk.find(query).update({ $set: { level: levels[i][0] } });
} }
const i = levels.length - 1; const i = levels.length - 1;
report({ message: 'Updating users levelled {0}'.format(levels[i][0]) });
bulk.find({ domainId, rank: { $lte: levels[i][1] } }).update({ $set: { level: levels[i][0] } }); bulk.find({ domainId, rank: { $lte: levels[i][1] } }).update({ $set: { level: levels[i][0] } });
await bulk.execute(); await bulk.execute();
} }
+16 -33
View File
@@ -303,19 +303,12 @@ export class HandlerCommon {
} }
try { try {
const { anchor } = args; const { anchor } = args;
if (!this.domain.host) { if (args.domainId) name += '_with_domainId';
if (this.domainId !== 'system' || args.domainId) { else if (this.domain.host !== this.request.host && this.domainId !== 'system') {
name += '_with_domainId'; name += '_with_domainId';
args.domainId = args.domainId || this.domainId; args.domainId = this.domainId;
}
res = router.url(name, args, { query });
} else {
if ((this.request.path || '').startsWith('/d/')) {
name += '_with_domainId';
args.domainId = args.domainId || this.domainId;
}
res = `//${this.domain.host}${router.url(name, args, { query })}`;
} }
res = router.url(name, args, { query });
if (anchor) return `${res}#${anchor}`; if (anchor) return `${res}#${anchor}`;
} catch (e) { } catch (e) {
logger.warn(e.message); logger.warn(e.message);
@@ -546,29 +539,19 @@ export class Handler extends HandlerCommon {
const expireSeconds = this.session.save const expireSeconds = this.session.save
? system.get('session.expire_seconds') ? system.get('session.expire_seconds')
: system.get('session.unsaved_expire_seconds'); : system.get('session.unsaved_expire_seconds');
const $update = {
updateIp: this.request.ip,
updateUa: this.request.headers['user-agent'] || '',
};
const $create = {
createIp: this.request.ip,
createUa: this.request.headers['user-agent'] || '',
createHost: this.request.host,
};
if (this.session._id) { if (this.session._id) {
await token.update( await token.update(this.session._id, token.TYPE_SESSION, expireSeconds, { ...this.session, ...$update });
this.session._id,
token.TYPE_SESSION,
expireSeconds,
{
...this.session,
updateIp: this.request.ip,
updateUa: this.request.headers['user-agent'] || '',
},
);
} else { } else {
[, this.session] = await token.add( [, this.session] = await token.add(token.TYPE_SESSION, expireSeconds, { ...this.session, ...$update, ...$create });
token.TYPE_SESSION,
expireSeconds,
{
...this.session,
createIp: this.request.ip,
createUa: this.request.headers['user-agent'] || '',
updateIp: this.request.ip,
updateUa: this.request.headers['user-agent'] || '',
},
);
} }
const cookie: SetOption = { const cookie: SetOption = {
secure: !!system.get('session.secure'), secure: !!system.get('session.secure'),