mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: 添加登录域名记录
This commit is contained in:
1 parent
3c4256be84
commit
66639b14de
4 files changed
+13
-32
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.17.0",
|
||||
"version": "2.17.1",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -281,7 +281,6 @@ export class ProblemPretestHandler extends ProblemDetailHandler {
|
||||
@param('input', Types.String, true)
|
||||
async post(domainId: string, lang: string, code: string, input: string = '') {
|
||||
this.limitRate('add_record', 3600, 100);
|
||||
// TODO parseConfig
|
||||
const rid = await record.add(
|
||||
domainId, this.pdoc.docId, this.user._id,
|
||||
lang, code, true,
|
||||
|
||||
@@ -116,7 +116,6 @@ export async function calcLevel(domainId: string, report: Function) {
|
||||
bulk.find(query).update({ $set: { level: levels[i][0] } });
|
||||
}
|
||||
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] } });
|
||||
await bulk.execute();
|
||||
}
|
||||
|
||||
@@ -303,19 +303,12 @@ export class HandlerCommon {
|
||||
}
|
||||
try {
|
||||
const { anchor } = args;
|
||||
if (!this.domain.host) {
|
||||
if (this.domainId !== 'system' || args.domainId) {
|
||||
if (args.domainId) name += '_with_domainId';
|
||||
else if (this.domain.host !== this.request.host && this.domainId !== 'system') {
|
||||
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 })}`;
|
||||
}
|
||||
if (anchor) return `${res}#${anchor}`;
|
||||
} catch (e) {
|
||||
logger.warn(e.message);
|
||||
@@ -546,29 +539,19 @@ export class Handler extends HandlerCommon {
|
||||
const expireSeconds = this.session.save
|
||||
? system.get('session.expire_seconds')
|
||||
: system.get('session.unsaved_expire_seconds');
|
||||
if (this.session._id) {
|
||||
await token.update(
|
||||
this.session._id,
|
||||
token.TYPE_SESSION,
|
||||
expireSeconds,
|
||||
{
|
||||
...this.session,
|
||||
const $update = {
|
||||
updateIp: this.request.ip,
|
||||
updateUa: this.request.headers['user-agent'] || '',
|
||||
},
|
||||
);
|
||||
} else {
|
||||
[, this.session] = await token.add(
|
||||
token.TYPE_SESSION,
|
||||
expireSeconds,
|
||||
{
|
||||
...this.session,
|
||||
};
|
||||
const $create = {
|
||||
createIp: this.request.ip,
|
||||
createUa: this.request.headers['user-agent'] || '',
|
||||
updateIp: this.request.ip,
|
||||
updateUa: this.request.headers['user-agent'] || '',
|
||||
},
|
||||
);
|
||||
createHost: this.request.host,
|
||||
};
|
||||
if (this.session._id) {
|
||||
await token.update(this.session._id, token.TYPE_SESSION, expireSeconds, { ...this.session, ...$update });
|
||||
} else {
|
||||
[, this.session] = await token.add(token.TYPE_SESSION, expireSeconds, { ...this.session, ...$update, ...$create });
|
||||
}
|
||||
const cookie: SetOption = {
|
||||
secure: !!system.get('session.secure'),
|
||||
|
||||
Reference in new issue
Block a user