diff --git a/packages/ui/certd-client/src/views/certd/mine/security/api.ts b/packages/ui/certd-client/src/views/certd/mine/security/api.ts index e401a80cf..6ed4dcade 100644 --- a/packages/ui/certd-client/src/views/certd/mine/security/api.ts +++ b/packages/ui/certd-client/src/views/certd/mine/security/api.ts @@ -28,7 +28,7 @@ export async function TwoFactorAuthenticatorGet() { url: apiPrefix + "/twoFactor/authenticator/qrcode", method: "post", }); - return res as string; //base64 + return res as { qrcode: string; link: string; secret: string }; //base64 } export async function TwoFactorAuthenticatorSave(req: AuthenticatorSaveReq) { diff --git a/packages/ui/certd-client/src/views/certd/mine/security/index.vue b/packages/ui/certd-client/src/views/certd/mine/security/index.vue index 7973584c1..f416914e5 100644 --- a/packages/ui/certd-client/src/views/certd/mine/security/index.vue +++ b/packages/ui/certd-client/src/views/certd/mine/security/index.vue @@ -57,6 +57,17 @@
+
+
您也可以手动添加:
+
+ Secret: + +
+
+ Link: + +
+

{{ t("certd.step3") }}

@@ -97,6 +108,8 @@ const formState = reactive>({ const authenticatorForm = reactive({ qrcodeSrc: "", verifyCode: "", + link: "", + secret: "", open: false, }); @@ -110,9 +123,14 @@ watch( async open => { if (open) { //base64 转图片 - authenticatorForm.qrcodeSrc = await api.TwoFactorAuthenticatorGet(); + const { qrcode, link, secret } = await api.TwoFactorAuthenticatorGet(); + authenticatorForm.qrcodeSrc = qrcode; + authenticatorForm.link = link; + authenticatorForm.secret = secret; } else { authenticatorForm.qrcodeSrc = ""; + authenticatorForm.link = ""; + authenticatorForm.secret = ""; authenticatorForm.verifyCode = ""; } } diff --git a/packages/ui/certd-server/src/controller/user/mine/setting-two-factor-controller.ts b/packages/ui/certd-server/src/controller/user/mine/setting-two-factor-controller.ts index 22a805d67..9ef49f89b 100644 --- a/packages/ui/certd-server/src/controller/user/mine/setting-two-factor-controller.ts +++ b/packages/ui/certd-server/src/controller/user/mine/setting-two-factor-controller.ts @@ -48,8 +48,8 @@ export class UserTwoFactorSettingController extends BaseController { @Post("/authenticator/qrcode", { summary: Constants.per.authOnly }) async authenticatorQrcode() { const userId = this.getUserId(); - const qrcode = await this.twoFactorService.getAuthenticatorQrCode(userId); - return this.ok(qrcode); + const {qrcode,link,secret} = await this.twoFactorService.getAuthenticatorQrCode(userId); + return this.ok({qrcode,link,secret}); } @Post("/authenticator/save", { summary: Constants.per.authOnly }) diff --git a/packages/ui/certd-server/src/modules/mine/service/two-factor-service.ts b/packages/ui/certd-server/src/modules/mine/service/two-factor-service.ts index 16fb42f39..bb15cc42f 100644 --- a/packages/ui/certd-server/src/modules/mine/service/two-factor-service.ts +++ b/packages/ui/certd-server/src/modules/mine/service/two-factor-service.ts @@ -33,7 +33,8 @@ export class TwoFactorService { //生成qrcode base64 const qrcode = await import("qrcode"); - return await qrcode.toDataURL(qrcodeContent); + const qrcodeBase64 = await qrcode.toDataURL(qrcodeContent); + return {qrcode:qrcodeBase64,link:qrcodeContent,secret} }