修正提示及masterId的比对

main
expressgy 3 months ago
parent 8b6db376f3
commit 5f0fd5be6c
  1. 2
      src/application/auth-role/auth-role.service.ts
  2. 8
      src/application/core-dict/core-dict.service.ts
  3. 8
      src/application/core-env/core-env.service.ts
  4. 6
      src/application/core-menu/core-menu.service.ts
  5. 10
      src/application/core-service/core-service.service.ts
  6. 2
      src/config/configuration.ts

@ -76,7 +76,7 @@ export class AuthRoleService {
* */
public async create(createAuthRoleDto: CreateAuthRoleDto, guardInfo: GuardInfo) {
// ! 判断是否是root账户,非root账户无法设置为root
if (this.config.get<number>('masterId') !== guardInfo.userId && isTrueEnum(createAuthRoleDto.root)) {
if (this.config.get<number>('masterId') != guardInfo.userId && isTrueEnum(createAuthRoleDto.root)) {
throw new HttpException('没有权限创建原始角色!', HttpStatus.UNAUTHORIZED);
}

@ -65,7 +65,7 @@ export class CoreDictService {
* */
public async create(createCoreDictDto: CreateCoreDictDto, guardInfo: GuardInfo) {
// ! 判断是否是root账户,非root账户无法设置为root
if (this.config.get<number>('masterId') !== guardInfo.userId && isTrueEnum(createCoreDictDto.root)) {
if (this.config.get<number>('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<number>('masterId') !== guardInfo.userId && updateCoreDictDto.root !== undefined) {
if (this.config.get<number>('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<number>('masterId') !== guardInfo.userId) {
if (oldDict[0].root && this.config.get<number>('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<number>('masterId') !== guardInfo.userId) {
if (result[0].root && this.config.get<number>('masterId') != guardInfo.userId) {
throw new HttpException('原始字典,权限不足无法删除!', HttpStatus.BAD_REQUEST);
}

@ -72,7 +72,7 @@ export class CoreEnvService {
* */
public async create(createCoreEnvDto: CreateCoreEnvDto, guardInfo: GuardInfo) {
// ! 判断是否是root账户,非root账户无法设置为root
if (this.config.get<number>('masterId') !== guardInfo.userId && isTrueEnum(createCoreEnvDto.root)) {
if (this.config.get<number>('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<number>('masterId') !== guardInfo.userId && updateCoreEnvDto.root !== undefined) {
if (this.config.get<number>('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<number>('masterId') !== guardInfo.userId) {
if (oldEnv[0].root && this.config.get<number>('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<number>('masterId') !== guardInfo.userId) {
if (result[0].root && this.config.get<number>('masterId') != guardInfo.userId) {
throw new HttpException('原始变量,权限不足无法删除!', HttpStatus.BAD_REQUEST);
}

@ -81,7 +81,7 @@ export class CoreMenuService {
// ! 加目标锁,允许同名,所以就不加锁了
// ? 判断是不是pac,不是的话直接退出
if (this.config.get<number>('masterId') !== guardInfo.userId) {
if (this.config.get<number>('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<number>('masterId') !== guardInfo.userId) {
if (this.config.get<number>('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<number>('masterId') !== guardInfo.userId) {
if (this.config.get<number>('masterId') != guardInfo.userId) {
throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED);
}

@ -29,8 +29,8 @@ export class CoreServiceService {
* */
public async create(createCoreServiceDto: CreateCoreServiceDto, guardInfo: GuardInfo) {
// ! 判断是否是root账户
if (this.config.get<number>('masterId') !== guardInfo.userId) {
throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED);
if (this.config.get<number>('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<number>('masterId') !== guardInfo.userId) {
throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED);
if (this.config.get<number>('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<number>('masterId') !== guardInfo.userId) {
if (this.config.get<number>('masterId') != guardInfo.userId) {
throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED);
}

@ -69,7 +69,7 @@ export default () => ({
refreshTokenTime: 60 * 60 * 24 * 7,
// 客户端连续在线时间 10min 60 * 10
tokenTime: 10,
tokenTime: 60 * 10,
// token盐
secretKey: '326dea8337e8xsxa24f71ab960ea',

Loading…
Cancel
Save