mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: 更新 joinSettings 验证
This commit is contained in:
1 parent
90c8bfefe2
commit
9f64fef88d
3 files changed
+10
-11
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.13.32",
|
"version": "2.13.33",
|
||||||
"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",
|
||||||
|
|||||||
@@ -97,11 +97,11 @@ export const ProblemDataNotFoundError = Err('ProblemDataNotFoundError', NotFound
|
|||||||
export const MessageNotFoundError = Err('MessageNotFoundError', NotFoundError, 'Message {0} not found.');
|
export const MessageNotFoundError = Err('MessageNotFoundError', NotFoundError, 'Message {0} not found.');
|
||||||
export const DocumentNotFoundError = Err('DocumentNotFoundError', NotFoundError, 'Document {2} not found.');
|
export const DocumentNotFoundError = Err('DocumentNotFoundError', NotFoundError, 'Document {2} not found.');
|
||||||
|
|
||||||
export const ProblemNotFoundError = Err('ProblemNotFountError', DocumentNotFoundError, 'Problem {0} not found.');
|
export const ProblemNotFoundError = Err('ProblemNotFountError', DocumentNotFoundError, 'Problem {1} not found.');
|
||||||
export const SolutionNotFoundError = Err('SolutionNotFoundError', DocumentNotFoundError, 'Solution {0} not found.');
|
export const SolutionNotFoundError = Err('SolutionNotFoundError', DocumentNotFoundError, 'Solution {1} not found.');
|
||||||
export const TrainingNotFoundError = Err('TrainingNotFoundError', DocumentNotFoundError, 'Training {0} not found.');
|
export const TrainingNotFoundError = Err('TrainingNotFoundError', DocumentNotFoundError, 'Training {1} not found.');
|
||||||
export const ContestNotFoundError = Err('ContestNotFoundError', DocumentNotFoundError, 'Contest {0} not found.');
|
export const ContestNotFoundError = Err('ContestNotFoundError', DocumentNotFoundError, 'Contest {1} not found.');
|
||||||
export const DiscussionNotFoundError = Err('DiscussionNotFoundError', DocumentNotFoundError, 'Discussion {0} not found.');
|
export const DiscussionNotFoundError = Err('DiscussionNotFoundError', DocumentNotFoundError, 'Discussion {1} not found.');
|
||||||
export const DiscussionNodeNotFoundError = Err('DiscussionNodeNotFoundError', DocumentNotFoundError, 'Discussion node {1} not found.');
|
export const DiscussionNodeNotFoundError = Err('DiscussionNodeNotFoundError', DocumentNotFoundError, 'Discussion node {1} not found.');
|
||||||
|
|
||||||
export const InvalidOperationError = Err('InvalidOperationError', MethodNotAllowedError);
|
export const InvalidOperationError = Err('InvalidOperationError', MethodNotAllowedError);
|
||||||
|
|||||||
@@ -222,14 +222,13 @@ class DomainJoinApplicationsHandler extends ManageHandler {
|
|||||||
if (method === domain.JOIN_METHOD_NONE) joinSettings = null;
|
if (method === domain.JOIN_METHOD_NONE) joinSettings = null;
|
||||||
else {
|
else {
|
||||||
if (!roles.includes(role)) throw new ValidationError('role');
|
if (!roles.includes(role)) throw new ValidationError('role');
|
||||||
if (!domain.JOIN_EXPIRATION_RANGE[expire]) throw new ValidationError('expire');
|
if (expire === domain.JOIN_EXPIRATION_KEEP_CURRENT) joinSettings.expire = current.expire;
|
||||||
|
else if (expire === domain.JOIN_EXPIRATION_UNLIMITED) joinSettings.expire = null;
|
||||||
|
else if (!domain.JOIN_EXPIRATION_RANGE[expire]) throw new ValidationError('expire');
|
||||||
|
else joinSettings.expire = moment().add(expire, 'hours').toDate();
|
||||||
if (!current && expire === domain.JOIN_EXPIRATION_KEEP_CURRENT) throw new ValidationError('expire');
|
if (!current && expire === domain.JOIN_EXPIRATION_KEEP_CURRENT) throw new ValidationError('expire');
|
||||||
joinSettings = { method, role };
|
joinSettings = { method, role };
|
||||||
if (method === domain.JOIN_METHOD_CODE) joinSettings.code = invitationCode;
|
if (method === domain.JOIN_METHOD_CODE) joinSettings.code = invitationCode;
|
||||||
if (expire === domain.JOIN_EXPIRATION_KEEP_CURRENT) {
|
|
||||||
joinSettings.expire = current.expire;
|
|
||||||
} else if (expire === domain.JOIN_EXPIRATION_UNLIMITED) joinSettings.expire = null;
|
|
||||||
else joinSettings.expire = moment().add(expire, 'hours').toDate();
|
|
||||||
}
|
}
|
||||||
await domain.edit(this.domain._id, { join: joinSettings });
|
await domain.edit(this.domain._id, { join: joinSettings });
|
||||||
this.back();
|
this.back();
|
||||||
|
|||||||
Reference in new issue
Block a user