fix: 修复上传到cos报runtimeDepsService未初始化的问题

This commit is contained in:
xiaojunnuo
2026-07-15 01:09:57 +08:00
parent b91c9e4ea6
commit 167b303fae
53 changed files with 517 additions and 1533 deletions
@@ -1,8 +1,9 @@
import { importRuntime } from "@certd/pipeline";
import { Inject, Provide, Scope, ScopeEnum } from "@midwayjs/core";
import { UserSettingsService } from "./user-settings-service.js";
import { UserTwoFactorSetting } from "./models.js";
import { UserService } from "../../sys/authority/service/user-service.js";
import { RuntimeDepsService } from "../../runtime-deps/runtime-deps-service.js";
/**
* 授权
@@ -14,15 +15,12 @@ export class TwoFactorService {
userSettingsService: UserSettingsService;
@Inject()
userService: UserService;
@Inject()
runtimeDepsService: RuntimeDepsService;
async getAuthenticatorQrCode(userId: any) {
async getAuthenticatorQrCode(userId: any) {
const setting = await this.getSetting(userId);
const authenticatorSetting = setting.authenticator;
if (!authenticatorSetting.secret) {
const { authenticator } = await this.runtimeDepsService.importRuntime("otplib");
const { authenticator } = await importRuntime("otplib");
authenticatorSetting.secret = authenticator.generateSecret();
await this.userSettingsService.saveSetting(userId, null, setting);
@@ -41,7 +39,7 @@ export class TwoFactorService {
async saveAuthenticator(req: { userId: any; verifyCode: any }) {
const userId = req.userId;
const { authenticator } = await this.runtimeDepsService.importRuntime("otplib");
const { authenticator } = await importRuntime("otplib");
const setting = await this.getSetting(userId);
const authenticatorSetting = setting.authenticator;
@@ -80,7 +78,7 @@ export class TwoFactorService {
}
async verifyAuthenticatorCode(userId: any, verifyCode: string) {
const { authenticator } = await this.runtimeDepsService.importRuntime("otplib");
const { authenticator } = await importRuntime("otplib");
const setting = await this.getSetting(userId);
if (!setting.authenticator.enabled) {
throw new Error("authenticator 未开启");
@@ -91,3 +89,6 @@ export class TwoFactorService {
return true;
}
}