mirror of
https://github.com/certd/certd.git
synced 2026-05-13 19:47:55 +08:00
fix: 修复启动时报密钥备份不存在的问题
This commit is contained in:
@@ -12,8 +12,7 @@ export class EncryptService {
|
||||
@Inject()
|
||||
sysSettingService: SysSettingsService;
|
||||
|
||||
@Init()
|
||||
async init() {
|
||||
async doInit() {
|
||||
const secret: SysSecret = await this.sysSettingService.getSecret();
|
||||
this.encryptor = new Encryptor(secret.encryptSecret);
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import { AutoPrint } from "./auto-print.js";
|
||||
|
||||
@Autoload()
|
||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||
export class AutoRegister {
|
||||
export class AutoARegister { //这个A是必须,让他排在第一个 进行init,否则会被其他init模块抢先注册导致报错
|
||||
@Inject()
|
||||
autoInitSite: AutoInitSite;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { logger } from '@certd/basic';
|
||||
import { PlusService, SysInstallInfo, SysPrivateSettings, SysSettingsService } from '@certd/lib-server';
|
||||
import { EncryptService, PlusService, SysInstallInfo, SysPrivateSettings, SysSettingsService } from '@certd/lib-server';
|
||||
import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import crypto from 'crypto';
|
||||
import { nanoid } from 'nanoid';
|
||||
@@ -22,6 +22,10 @@ export class AutoInitSite {
|
||||
@Inject()
|
||||
safeService: SafeService;
|
||||
|
||||
@Inject()
|
||||
encryptService: EncryptService;
|
||||
|
||||
|
||||
async init() {
|
||||
logger.info('初始化站点开始');
|
||||
await this.startOptimizeDb();
|
||||
@@ -50,6 +54,8 @@ export class AutoInitSite {
|
||||
//加载一次密钥
|
||||
await this.sysSettingsService.getSecret();
|
||||
|
||||
//初始化加密服务
|
||||
await this.encryptService.doInit();
|
||||
|
||||
// 授权许可
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user