From 6477bf3649e6552eb5b6442890d421010e98583c Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Mon, 15 Jun 2026 11:35:34 +0800 Subject: [PATCH] perf: Login asset otp --- .../select-account.component.html | 15 ++ .../select-account.component.scss | 6 + .../select-account.component.ts | 9 ++ src/app/model.ts | 2 + src/app/services/app.ts | 2 + .../acl-dialog/acl-dialog.component.html | 23 ++- .../acl-dialog/acl-dialog.component.scss | 10 ++ .../acl-dialog/acl-dialog.component.ts | 143 +++++++++++++++++- src/app/services/http.ts | 27 +++- src/assets/i18n/en.json | 4 + src/assets/i18n/ja.json | 4 + src/assets/i18n/zh-hans.json | 5 +- src/assets/i18n/zh-hant.json | 4 + 13 files changed, 242 insertions(+), 12 deletions(-) diff --git a/src/app/elements/connect/connect-dialog/select-account/select-account.component.html b/src/app/elements/connect/connect-dialog/select-account/select-account.component.html index 6d6af31c9..844c193a5 100644 --- a/src/app/elements/connect/connect-dialog/select-account/select-account.component.html +++ b/src/app/elements/connect/connect-dialog/select-account/select-account.component.html @@ -75,5 +75,20 @@ + + {{ "OTP Code" | translate }} + + + + diff --git a/src/app/elements/connect/connect-dialog/select-account/select-account.component.scss b/src/app/elements/connect/connect-dialog/select-account/select-account.component.scss index c239e06f0..3e762461b 100644 --- a/src/app/elements/connect/connect-dialog/select-account/select-account.component.scss +++ b/src/app/elements/connect/connect-dialog/select-account/select-account.component.scss @@ -32,6 +32,12 @@ } } +.otp-code { + ::ng-deep .ant-input { + width: 70%; + } +} + .input-field { width: 100%; } diff --git a/src/app/elements/connect/connect-dialog/select-account/select-account.component.ts b/src/app/elements/connect/connect-dialog/select-account/select-account.component.ts index 8d23781bf..873d7843a 100644 --- a/src/app/elements/connect/connect-dialog/select-account/select-account.component.ts +++ b/src/app/elements/connect/connect-dialog/select-account/select-account.component.ts @@ -111,6 +111,12 @@ export class ElementSelectAccountComponent implements OnInit, OnDestroy { return this.accountSelected.username === '@INPUT' || this.accountSelected.username === '@USER'; } + get showOTPCodeInput() { + return !!this.accountSelected && + this.accountSelected.username !== '@ANON' && + !!this.accountSelected.has_otp_secret_key; + } + public compareFn = (f1: Account, f2: Account) => { if (!f1 || !f2) return false; return f1.alias === f2.alias && f1.id === f2.id; @@ -298,6 +304,7 @@ export class ElementSelectAccountComponent implements OnInit, OnDestroy { if (!this.accountSelected) { return; } + this.manualAuthInfo.otp_code = ''; if (this.accountSelected.has_secret) { return; } @@ -317,6 +324,7 @@ export class ElementSelectAccountComponent implements OnInit, OnDestroy { } if (this.localAuthItems && this.localAuthItems.length > 0) { this.manualAuthInfo = Object.assign(this.manualAuthInfo, this.localAuthItems[0]); + this.manualAuthInfo.otp_code = ''; } this.setUsernamePlaceholder(); setTimeout(() => { @@ -342,6 +350,7 @@ export class ElementSelectAccountComponent implements OnInit, OnDestroy { this.filteredOptions = this.localAuthItems.filter(authInfo => { if (authInfo.username.toLowerCase() === filterValue) { this.manualAuthInfo = Object.assign(this.manualAuthInfo, authInfo); + this.manualAuthInfo.otp_code = ''; } return authInfo.username.toLowerCase().includes(filterValue); }); diff --git a/src/app/model.ts b/src/app/model.ts index 738deb362..ddbe17bd2 100644 --- a/src/app/model.ts +++ b/src/app/model.ts @@ -34,6 +34,7 @@ export class Account { name: string; username: string; has_secret: boolean; + has_otp_secret_key: boolean; secret: string; actions: Array; id?: string; @@ -401,6 +402,7 @@ export class AuthInfo { alias: string; username: string; secret: string; + otp_code: string; rememberAuth: boolean; } diff --git a/src/app/services/app.ts b/src/app/services/app.ts index 37ba9aa1e..85b293878 100644 --- a/src/app/services/app.ts +++ b/src/app/services/app.ts @@ -348,6 +348,7 @@ export class AppService { for (const auth of auths) { const newAuth = Object.assign({}, auth); newAuth.secret = this.decrypt(newAuth.secret); + newAuth.otp_code = ''; newAuths.push(newAuth); } return newAuths; @@ -356,6 +357,7 @@ export class AppService { setAccountLocalAuth(asset: Asset, account: Account, auth: AuthInfo) { const assetId = asset.id; const newAuth = Object.assign({ alias: account.alias, username: account.username }, auth); + newAuth.otp_code = ''; // 如果 auth.alias 是 undefined,保持使用 account.alias if (auth.alias === undefined && account.alias !== undefined) { diff --git a/src/app/services/connect-token/acl-dialog/acl-dialog.component.html b/src/app/services/connect-token/acl-dialog/acl-dialog.component.html index 88bf53a5b..51d075c0c 100644 --- a/src/app/services/connect-token/acl-dialog/acl-dialog.component.html +++ b/src/app/services/connect-token/acl-dialog/acl-dialog.component.html @@ -29,6 +29,22 @@
+ + +
+ +
{{ otpCodeError }}
+
+
@@ -47,7 +63,12 @@