refactor(server): permission (#10449)

This commit is contained in:
liuyi
2025-03-05 15:57:00 +08:00
committed by GitHub
parent bf7b1646b3
commit 61162c59fc
61 changed files with 2680 additions and 3562 deletions

View File

@@ -419,6 +419,14 @@ export const USER_FRIENDLY_ERRORS = {
args: { spaceId: 'string' },
message: 'Space should have only one owner.',
},
owner_can_not_leave_workspace: {
type: 'action_forbidden',
message: 'Owner can not leave the workspace.',
},
can_not_revoke_yourself: {
type: 'action_forbidden',
message: 'You can not revoke your own permission.',
},
doc_not_found: {
type: 'resource_not_found',
args: { spaceId: 'string', docId: 'string' },

View File

@@ -298,6 +298,18 @@ export class SpaceShouldHaveOnlyOneOwner extends UserFriendlyError {
super('invalid_input', 'space_should_have_only_one_owner', message, args);
}
}
export class OwnerCanNotLeaveWorkspace extends UserFriendlyError {
constructor(message?: string) {
super('action_forbidden', 'owner_can_not_leave_workspace', message);
}
}
export class CanNotRevokeYourself extends UserFriendlyError {
constructor(message?: string) {
super('action_forbidden', 'can_not_revoke_yourself', message);
}
}
@ObjectType()
class DocNotFoundDataType {
@Field() spaceId!: string
@@ -855,6 +867,8 @@ export enum ErrorNames {
SPACE_ACCESS_DENIED,
SPACE_OWNER_NOT_FOUND,
SPACE_SHOULD_HAVE_ONLY_ONE_OWNER,
OWNER_CAN_NOT_LEAVE_WORKSPACE,
CAN_NOT_REVOKE_YOURSELF,
DOC_NOT_FOUND,
DOC_ACTION_DENIED,
VERSION_REJECTED,