mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 12:36:24 +08:00
refactor(server): permission (#10449)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user