From 5f0fd5be6c89e738ac9f36142591fc1885805304 Mon Sep 17 00:00:00 2001 From: expressgy Date: Tue, 2 Jul 2024 02:04:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8F=90=E7=A4=BA=E5=8F=8Ama?= =?UTF-8?q?sterId=E7=9A=84=E6=AF=94=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/application/auth-role/auth-role.service.ts | 2 +- src/application/core-dict/core-dict.service.ts | 8 ++++---- src/application/core-env/core-env.service.ts | 8 ++++---- src/application/core-menu/core-menu.service.ts | 6 +++--- src/application/core-service/core-service.service.ts | 10 +++++----- src/config/configuration.ts | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/application/auth-role/auth-role.service.ts b/src/application/auth-role/auth-role.service.ts index e39db64..e3fa71e 100644 --- a/src/application/auth-role/auth-role.service.ts +++ b/src/application/auth-role/auth-role.service.ts @@ -76,7 +76,7 @@ export class AuthRoleService { * */ public async create(createAuthRoleDto: CreateAuthRoleDto, guardInfo: GuardInfo) { // ! 判断是否是root账户,非root账户无法设置为root - if (this.config.get('masterId') !== guardInfo.userId && isTrueEnum(createAuthRoleDto.root)) { + if (this.config.get('masterId') != guardInfo.userId && isTrueEnum(createAuthRoleDto.root)) { throw new HttpException('没有权限创建原始角色!', HttpStatus.UNAUTHORIZED); } diff --git a/src/application/core-dict/core-dict.service.ts b/src/application/core-dict/core-dict.service.ts index 5e5aab3..dcb24c6 100644 --- a/src/application/core-dict/core-dict.service.ts +++ b/src/application/core-dict/core-dict.service.ts @@ -65,7 +65,7 @@ export class CoreDictService { * */ public async create(createCoreDictDto: CreateCoreDictDto, guardInfo: GuardInfo) { // ! 判断是否是root账户,非root账户无法设置为root - if (this.config.get('masterId') !== guardInfo.userId && isTrueEnum(createCoreDictDto.root)) { + if (this.config.get('masterId') != guardInfo.userId && isTrueEnum(createCoreDictDto.root)) { throw new HttpException('没有权限创建原始字典!', HttpStatus.UNAUTHORIZED); } @@ -147,7 +147,7 @@ export class CoreDictService { * */ public async update(dictId: string, updateCoreDictDto: UpdateCoreDictDto, guardInfo: GuardInfo) { // ! 判断是否是root账户,非root账户无法设置为root - if (this.config.get('masterId') !== guardInfo.userId && updateCoreDictDto.root !== undefined) { + if (this.config.get('masterId') != guardInfo.userId && updateCoreDictDto.root !== undefined) { throw new HttpException('没有权限修改原始字典!', HttpStatus.UNAUTHORIZED); } @@ -156,7 +156,7 @@ export class CoreDictService { if (oldDict.length == 0) throw new HttpException('未找到目标字典,无法修改!', HttpStatus.BAD_REQUEST); // ! root数据,非root用户不允许修改 - if (oldDict[0].root && this.config.get('masterId') !== guardInfo.userId) { + if (oldDict[0].root && this.config.get('masterId') != guardInfo.userId) { throw new HttpException('原始字典,权限不足无法修改!', HttpStatus.BAD_REQUEST); } @@ -208,7 +208,7 @@ export class CoreDictService { } // ! root数据,非root用户不允许删除 - if (result[0].root && this.config.get('masterId') !== guardInfo.userId) { + if (result[0].root && this.config.get('masterId') != guardInfo.userId) { throw new HttpException('原始字典,权限不足无法删除!', HttpStatus.BAD_REQUEST); } diff --git a/src/application/core-env/core-env.service.ts b/src/application/core-env/core-env.service.ts index 75e8936..2a4490d 100644 --- a/src/application/core-env/core-env.service.ts +++ b/src/application/core-env/core-env.service.ts @@ -72,7 +72,7 @@ export class CoreEnvService { * */ public async create(createCoreEnvDto: CreateCoreEnvDto, guardInfo: GuardInfo) { // ! 判断是否是root账户,非root账户无法设置为root - if (this.config.get('masterId') !== guardInfo.userId && isTrueEnum(createCoreEnvDto.root)) { + if (this.config.get('masterId') != guardInfo.userId && isTrueEnum(createCoreEnvDto.root)) { throw new HttpException('没有权限创建原始变量!', HttpStatus.UNAUTHORIZED); } @@ -147,7 +147,7 @@ export class CoreEnvService { public async update(envId: string, updateCoreEnvDto: UpdateCoreEnvDto, guardInfo: GuardInfo) { // ! 判断是否是root账户,非root账户无法设置为root - if (this.config.get('masterId') !== guardInfo.userId && updateCoreEnvDto.root !== undefined) { + if (this.config.get('masterId') != guardInfo.userId && updateCoreEnvDto.root !== undefined) { throw new HttpException('没有权限修改原始字典!', HttpStatus.UNAUTHORIZED); } @@ -158,7 +158,7 @@ export class CoreEnvService { } // ! root数据,非root用户不允许修改 - if (oldEnv[0].root && this.config.get('masterId') !== guardInfo.userId) { + if (oldEnv[0].root && this.config.get('masterId') != guardInfo.userId) { throw new HttpException('原始变量,权限不足无法修改!', HttpStatus.BAD_REQUEST); } @@ -207,7 +207,7 @@ export class CoreEnvService { // ? 判断是否存在 if (result.length > 0) { // ! root数据,非root用户不允许删除 - if (result[0].root && this.config.get('masterId') !== guardInfo.userId) { + if (result[0].root && this.config.get('masterId') != guardInfo.userId) { throw new HttpException('原始变量,权限不足无法删除!', HttpStatus.BAD_REQUEST); } diff --git a/src/application/core-menu/core-menu.service.ts b/src/application/core-menu/core-menu.service.ts index 93f2903..f496088 100644 --- a/src/application/core-menu/core-menu.service.ts +++ b/src/application/core-menu/core-menu.service.ts @@ -81,7 +81,7 @@ export class CoreMenuService { // ! 加目标锁,允许同名,所以就不加锁了 // ? 判断是不是pac,不是的话直接退出 - if (this.config.get('masterId') !== guardInfo.userId) { + if (this.config.get('masterId') != guardInfo.userId) { throw new HttpException('没有权限添加菜单!', HttpStatus.UNAUTHORIZED); } @@ -111,7 +111,7 @@ export class CoreMenuService { public update(id: string, updateCoreMenuDto: UpdateCoreMenuDto, guardInfo: GuardInfo) { // ! 比较权限 - if (this.config.get('masterId') !== guardInfo.userId) { + if (this.config.get('masterId') != guardInfo.userId) { throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED); } @@ -120,7 +120,7 @@ export class CoreMenuService { public async remove(id: string, guardInfo: GuardInfo) { // ! 比较权限 - if (this.config.get('masterId') !== guardInfo.userId) { + if (this.config.get('masterId') != guardInfo.userId) { throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED); } diff --git a/src/application/core-service/core-service.service.ts b/src/application/core-service/core-service.service.ts index 2fa8689..2778770 100644 --- a/src/application/core-service/core-service.service.ts +++ b/src/application/core-service/core-service.service.ts @@ -29,8 +29,8 @@ export class CoreServiceService { * */ public async create(createCoreServiceDto: CreateCoreServiceDto, guardInfo: GuardInfo) { // ! 判断是否是root账户 - if (this.config.get('masterId') !== guardInfo.userId) { - throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED); + if (this.config.get('masterId') != guardInfo.userId) { + throw new HttpException('没有权限创建菜单!', HttpStatus.UNAUTHORIZED); } // ! 上锁 @@ -88,8 +88,8 @@ export class CoreServiceService { * */ public async update(serviceKey: string, updateCoreServiceDto: UpdateCoreServiceDto, guardInfo: GuardInfo) { // ! 判断是否是root账户 - if (this.config.get('masterId') !== guardInfo.userId) { - throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED); + if (this.config.get('masterId') != guardInfo.userId) { + throw new HttpException('没有权限修改菜单!', HttpStatus.UNAUTHORIZED); } // ! 查找目标服务是否存在 @@ -143,7 +143,7 @@ export class CoreServiceService { * */ public async remove(serviceKey: string, guardInfo: GuardInfo) { // ! 判断是否是root账户 - if (this.config.get('masterId') !== guardInfo.userId) { + if (this.config.get('masterId') != guardInfo.userId) { throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED); } diff --git a/src/config/configuration.ts b/src/config/configuration.ts index 674bf2c..9640613 100644 --- a/src/config/configuration.ts +++ b/src/config/configuration.ts @@ -69,7 +69,7 @@ export default () => ({ refreshTokenTime: 60 * 60 * 24 * 7, // 客户端连续在线时间 10min 60 * 10 - tokenTime: 10, + tokenTime: 60 * 10, // token盐 secretKey: '326dea8337e8xsxa24f71ab960ea',