mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01: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",
|
"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",
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 });
|
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}`;
|
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');
|
||||||
if (this.session._id) {
|
const $update = {
|
||||||
await token.update(
|
|
||||||
this.session._id,
|
|
||||||
token.TYPE_SESSION,
|
|
||||||
expireSeconds,
|
|
||||||
{
|
|
||||||
...this.session,
|
|
||||||
updateIp: this.request.ip,
|
updateIp: this.request.ip,
|
||||||
updateUa: this.request.headers['user-agent'] || '',
|
updateUa: this.request.headers['user-agent'] || '',
|
||||||
},
|
};
|
||||||
);
|
const $create = {
|
||||||
} else {
|
|
||||||
[, this.session] = await token.add(
|
|
||||||
token.TYPE_SESSION,
|
|
||||||
expireSeconds,
|
|
||||||
{
|
|
||||||
...this.session,
|
|
||||||
createIp: this.request.ip,
|
createIp: this.request.ip,
|
||||||
createUa: this.request.headers['user-agent'] || '',
|
createUa: this.request.headers['user-agent'] || '',
|
||||||
updateIp: this.request.ip,
|
createHost: this.request.host,
|
||||||
updateUa: this.request.headers['user-agent'] || '',
|
};
|
||||||
},
|
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 = {
|
const cookie: SetOption = {
|
||||||
secure: !!system.get('session.secure'),
|
secure: !!system.get('session.secure'),
|
||||||
|
|||||||
Reference in new issue
Block a user