mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: support ban user from domain
This commit is contained in:
8 files changed
+15
-6
No files matched your search
@@ -345,7 +345,8 @@ class DomainJoinHandler extends Handler {
|
||||
const roles = r.map((role) => role._id);
|
||||
this.joinSettings = domain.getJoinSettings(ddoc, roles);
|
||||
if (assignedRole !== 'default') delete this.joinSettings;
|
||||
else if (!this.joinSettings) throw new DomainJoinForbiddenError(target);
|
||||
else if (!this.joinSettings) throw new DomainJoinForbiddenError(target, 'The link is either invalid or expired.');
|
||||
if (assignedRole === 'guest') throw new DomainJoinForbiddenError(target, 'You are banned by the domain moderator.');
|
||||
}
|
||||
|
||||
@param('code', Types.Content, true)
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Binary, ObjectId } from 'mongodb';
|
||||
import { UAParser } from 'ua-parser-js';
|
||||
import { Context } from '../context';
|
||||
import {
|
||||
AuthOperationError, BlacklistedError, DomainAlreadyExistsError, InvalidTokenError,
|
||||
AuthOperationError, BadRequestError, BlacklistedError, DomainAlreadyExistsError, InvalidTokenError,
|
||||
NotFoundError, PermissionError, UserAlreadyExistError,
|
||||
UserNotFoundError, ValidationError, VerifyPasswordError,
|
||||
} from '../error';
|
||||
@@ -507,6 +507,7 @@ class HomeDomainHandler extends Handler {
|
||||
|
||||
@param('id', Types.String)
|
||||
async postLeave({ }, id: string) {
|
||||
if (id === 'system') throw new BadRequestError();
|
||||
const ddoc = await domain.get(id);
|
||||
if (!ddoc) throw new NotFoundError(id);
|
||||
await domain.setJoin(id, this.user._id, false);
|
||||
|
||||
Reference in new issue
Block a user