core: 优化比赛模块鉴权(比赛结束时可自由查看题目)

This commit is contained in:
undefined committed 2020-11-14 13:00:16 +08:00
1 parent 99e0d2fb14
commit c1da60a37e
4 files changed
+5 -4

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.13.50",
"version": "2.13.51",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+1 -1
View File
@@ -59,7 +59,7 @@ export async function load(call: Entry) {
for (const i of builtinModel) require(`../model/${i}`);
const modelSystem = require('../model/system');
const scripts = require('../upgrade');
let dbVer = (await modelSystem.get('db.ver')) || 0;
let dbVer = (await modelSystem.get('db.ver')) ?? 0;
const expected = scripts.length;
while (dbVer < expected) {
logger.info('Upgrading database: from %d to %d', dbVer, expected);
+2 -1
View File
@@ -241,7 +241,7 @@ class ContestProblemHandler extends ContestHandler {
]);
this.attended = this.tsdoc && this.tsdoc.attend === 1;
this.response.template = 'problem_detail.html';
if (contest.isDone(this.tdoc)) {
if (!contest.isDone(this.tdoc)) {
if (!this.attended) throw new ContestNotAttendedError(this.tdoc.docId);
if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId);
}
@@ -272,6 +272,7 @@ class ContestProblemSubmitHandler extends ContestProblemHandler {
@param('tid', Types.ObjectID)
@param('pid', Types.UnsignedInt)
async prepare(domainId: string, tid: ObjectID, pid: number) {
if (contest.isOngoing(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId);
let rdocs = [];
if (this.canShowRecord(this.tdoc)) {
rdocs = await record.getUserInProblemMulti(
+1 -1
View File
@@ -138,7 +138,7 @@ SystemSetting(
Setting('setting_session', 'session.secure', null, false, 'boolean', 'session.secure'),
Setting('setting_session', 'session.saved_expire_seconds', null, 3600 * 24 * 30, 'number', 'Saved session expire seconds'),
Setting('setting_session', 'session.unsaved_expire_seconds', null, 3600 * 3, 'number', 'Unsaved session expire seconds'),
Setting('setting_storage', 'db.ver', null, 1, 'number', 'Database version', null, FLAG_DISABLED | FLAG_HIDDEN),
Setting('setting_storage', 'db.ver', null, 0, 'number', 'Database version', null, FLAG_DISABLED | FLAG_HIDDEN),
Setting('setting_storage', 'user', null, 1, 'number', 'User Counter', null, FLAG_DISABLED | FLAG_HIDDEN),
);