This commit is contained in:
xiaojunnuo
2024-11-01 00:59:09 +08:00
parent b817cb4a1b
commit 0165ccbaac
17 changed files with 131 additions and 47 deletions
+3 -5
View File
@@ -73,7 +73,6 @@
"lodash-es": "^4.17.21",
"log4js": "^6.7.1",
"lru-cache": "^11.0.1",
"md5": "^2.3.0",
"mwtsc": "^1.4.0",
"nanoid": "^5.0.7",
"node-forge": "^1.3.1",
@@ -89,10 +88,11 @@
"ssh2": "^1.15.0",
"strip-ansi": "^7.1.0",
"svg-captcha": "^1.4.0",
"syno": "^2.2.0",
"tencentcloud-sdk-nodejs": "^4.0.44",
"typeorm": "^0.3.20",
"uuid": "^10.0.0"
"uuid": "^10.0.0",
"mwts": "^1.3.0",
"cross-env": "^7.0.3"
},
"devDependencies": {
"@midwayjs/mock": "~3.17.1",
@@ -106,9 +106,7 @@
"@types/nodemailer": "^6.4.8",
"@types/ssh2": "^1.15.0",
"c8": "^10.1.2",
"cross-env": "^7.0.3",
"mocha": "^10.2.0",
"mwts": "^1.3.0",
"prettier": "^3.3.3",
"rimraf": "^5.0.5",
"ts-node": "^10.9.2",
@@ -0,0 +1,23 @@
import { Controller, Get, Provide } from '@midwayjs/core';
import { BaseController, Constants } from '@certd/lib-server';
import { http, logger } from '@certd/pipeline';
/**
*/
@Provide()
@Controller('/api/app/')
export class AppController extends BaseController {
@Get('/latest', { summary: Constants.per.authOnly })
async latest(): Promise<any> {
const res = await http.request({
url: 'https://registry.npmmirror.com/@certd/pipeline',
method: 'get',
});
try {
const latest = res['dist-tags'].latest;
return this.ok(latest);
} catch (e: any) {
logger.error(e);
return this.ok('');
}
}
}
@@ -1,5 +1,4 @@
import { MidwayEnvironmentService } from '@midwayjs/core';
import { Controller, Get, Inject, Provide } from '@midwayjs/core';
import { Controller, Get, Inject, MidwayEnvironmentService, Provide } from '@midwayjs/core';
import { logger } from '@certd/pipeline';
import { Constants } from '@certd/lib-server';
@@ -1,7 +1,6 @@
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
import { CrudController } from '@certd/lib-server';
import { Constants, CrudController } from '@certd/lib-server';
import { AccessService } from '../../modules/pipeline/service/access-service.js';
import { Constants } from '@certd/lib-server';
/**
* 授权
@@ -78,9 +77,6 @@ export class AccessController extends CrudController<AccessService> {
const list = this.service.getDefineList();
const dict = [];
for (const item of list) {
if (item?.deprecated) {
continue;
}
dict.push({
value: item.name,
label: item.title,
@@ -49,6 +49,9 @@ export class RoleService extends BaseService<RoleEntity> {
}
async getPermissionByRoleIds(roleIds: any) {
if (!roleIds || roleIds.length === 0) {
return [];
}
return await this.permissionService.repository
.createQueryBuilder('permission')
.innerJoinAndSelect(RolePermissionEntity, 'rp', 'rp.permissionId = permission.id and rp.roleId in (:...roleIds)', { roleIds })
@@ -3,7 +3,6 @@ import { InjectEntityModel } from '@midwayjs/typeorm';
import { MoreThan, Repository } from 'typeorm';
import { UserEntity } from '../entity/user.js';
import * as _ from 'lodash-es';
import md5 from 'md5';
import { BaseService, CommonException, Constants, FileService, SysInstallInfo, SysSettingsService } from '@certd/lib-server';
import { RoleService } from './role-service.js';
import { PermissionService } from './permission-service.js';
@@ -13,7 +12,7 @@ import bcrypt from 'bcryptjs';
import { RandomUtil } from '../../../../utils/random.js';
import dayjs from 'dayjs';
import { DbAdapter } from '../../../db/index.js';
import { utils } from '@certd/pipeline';
/**
* 系统用户
*/
@@ -116,7 +115,7 @@ export class UserService extends BaseService<UserEntity> {
private async genPassword(rawPassword: any, passwordVersion: number) {
if (passwordVersion == null || passwordVersion <= 1) {
return md5(rawPassword);
return utils.hash.md5(rawPassword);
}
const salt = bcrypt.genSaltSync(10);
const plainPassword = await this.buildPlainPassword(rawPassword);
@@ -1,5 +1,5 @@
import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
import { isDev } from "../../utils/env.js";
import { isDev } from '../../utils/env.js';
/**
* 这个注解将注册一个授权配置