core: 更新 joinSettings 验证

This commit is contained in:
undefined committed 2020-10-31 23:25:53 +08:00
1 parent 90c8bfefe2
commit 9f64fef88d
3 files changed
+10 -11

No files matched your search

+4 -5
View File
@@ -222,14 +222,13 @@ class DomainJoinApplicationsHandler extends ManageHandler {
if (method === domain.JOIN_METHOD_NONE) joinSettings = null;
else {
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');
joinSettings = { method, role };
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 });
this.back();