roles update
This commit is contained in:
@@ -166,6 +166,8 @@ export class AuthGrpcController {
|
||||
slug: role.slug,
|
||||
name: role.name,
|
||||
description: role.description ?? undefined,
|
||||
isSystem: role.isSystem,
|
||||
isDefault: role.isDefault,
|
||||
permissions: role.permissions.map((link) => ({
|
||||
id: link.permission.id,
|
||||
slug: link.permission.slug,
|
||||
@@ -234,6 +236,8 @@ export class AuthGrpcController {
|
||||
slug: role.slug,
|
||||
name: role.name,
|
||||
description: role.description ?? undefined,
|
||||
isSystem: role.isSystem,
|
||||
isDefault: role.isDefault,
|
||||
permissions: role.permissions.map((link) => ({
|
||||
id: link.permission.id,
|
||||
slug: link.permission.slug,
|
||||
@@ -243,6 +247,41 @@ export class AuthGrpcController {
|
||||
};
|
||||
}
|
||||
|
||||
@GrpcMethod('RbacService', 'UpdateRole')
|
||||
async updateRole(command: {
|
||||
actorUserId: string;
|
||||
roleSlug: string;
|
||||
name?: string;
|
||||
description?: string;
|
||||
permissionSlugs?: string[];
|
||||
}) {
|
||||
const role = await this.rbac.updateRole(command.actorUserId, command.roleSlug, {
|
||||
name: command.name,
|
||||
description: command.description,
|
||||
permissionSlugs: command.permissionSlugs
|
||||
});
|
||||
return {
|
||||
id: role.id,
|
||||
slug: role.slug,
|
||||
name: role.name,
|
||||
description: role.description ?? undefined,
|
||||
isSystem: role.isSystem,
|
||||
isDefault: role.isDefault,
|
||||
permissions: role.permissions.map((link) => ({
|
||||
id: link.permission.id,
|
||||
slug: link.permission.slug,
|
||||
name: link.permission.name,
|
||||
description: link.permission.description ?? undefined
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
@GrpcMethod('RbacService', 'DeleteRole')
|
||||
async deleteRole(command: { actorUserId: string; roleSlug: string }) {
|
||||
await this.rbac.deleteRole(command.actorUserId, command.roleSlug);
|
||||
return {};
|
||||
}
|
||||
|
||||
@GrpcMethod('RbacService', 'AssignUserRole')
|
||||
async assignUserRole(command: { actorUserId: string; userId: string; roleSlug: string }) {
|
||||
const roles = await this.rbac.assignRole(command.actorUserId, command.userId, command.roleSlug);
|
||||
@@ -255,6 +294,18 @@ export class AuthGrpcController {
|
||||
return {};
|
||||
}
|
||||
|
||||
@GrpcMethod('RbacService', 'AssignUserPermission')
|
||||
async assignUserPermission(command: { actorUserId: string; userId: string; permissionSlug: string }) {
|
||||
const permissions = await this.rbac.assignUserPermission(command.actorUserId, command.userId, command.permissionSlug);
|
||||
return { userId: command.userId, permissions };
|
||||
}
|
||||
|
||||
@GrpcMethod('RbacService', 'RemoveUserPermission')
|
||||
async removeUserPermission(command: { actorUserId: string; userId: string; permissionSlug: string }) {
|
||||
const permissions = await this.rbac.removeUserPermission(command.actorUserId, command.userId, command.permissionSlug);
|
||||
return { userId: command.userId, permissions };
|
||||
}
|
||||
|
||||
@GrpcMethod('RbacService', 'CreateOAuthClient')
|
||||
async createOAuthClient(command: { actorUserId: string; name: string; redirectUris: string[]; scopes: string[]; type?: string }) {
|
||||
const { client, clientSecret } = await this.rbac.createOAuthClient(command.actorUserId, {
|
||||
@@ -306,6 +357,11 @@ export class AuthGrpcController {
|
||||
return this.rbac.rotateOAuthSecret(command.actorUserId, command.clientId);
|
||||
}
|
||||
|
||||
@GrpcMethod('RbacService', 'DeleteOAuthClient')
|
||||
async deleteOAuthClient(command: { actorUserId: string; clientId: string }) {
|
||||
return this.rbac.deleteOAuthClient(command.actorUserId, command.clientId);
|
||||
}
|
||||
|
||||
@GrpcMethod('SecurityService', 'ListActiveDevices')
|
||||
async listActiveDevices(command: { userId: string; exceptSessionId?: string }) {
|
||||
const devices = await this.security.listActiveDevices(command.userId, command.exceptSessionId);
|
||||
|
||||
Reference in New Issue
Block a user