From 0d4420c41a5f81171b7432ef8411b43c55fa0e7f Mon Sep 17 00:00:00 2001 From: rustdreamer Date: Wed, 8 May 2024 01:21:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=A7=92=E8=89=B2=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/user/user.controller.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts index ad57d00..0694300 100644 --- a/src/user/user.controller.ts +++ b/src/user/user.controller.ts @@ -61,8 +61,10 @@ export class UserController { async viewer(@User() viewer: UserEntity) { const result = await this.userRepository.findOne({ where: { id: viewer.id } }) const role = await this.roleRepository.findOne({ where: { id: result.role_id } }) - if (role) { - (result as any).permissions = role.permissions.split('、'); + if (role && role.permissions) { + (result as any).permissions = [...role.permissions.split('、'), result.role]; + } else { + (result as any).permissions = [result.role]; } return result; }