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
+8 -2
View File
@@ -10,6 +10,7 @@ import {
WrongSignInMethod,
} from '../base';
import { BaseModel } from './base';
import { WorkspaceRole } from './common';
import type { Workspace } from './workspace';
const publicUserSelect = {
@@ -215,12 +216,17 @@ export class UserModel extends BaseModel {
}
async delete(id: string) {
const ownedWorkspaceIds = await this.models.workspace.findOwnedIds(id);
const ownedWorkspaces = await this.models.workspaceUser.getUserActiveRoles(
id,
{
role: WorkspaceRole.Owner,
}
);
const user = await this.db.user.delete({ where: { id } });
this.event.emit('user.deleted', {
...user,
ownedWorkspaces: ownedWorkspaceIds,
ownedWorkspaces: ownedWorkspaces.map(r => r.workspaceId),
});
return user;