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; }