From 64eb1c2ebfc25f11f5757a0eef04de230fa8fa15 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 04 十二月 2025 17:52:54 +0800
Subject: [PATCH] fix: 账号密码双因子登录
---
src/views/Login/Login.vue | 57 +++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/src/views/Login/Login.vue b/src/views/Login/Login.vue
index 774987f..3d476ee 100644
--- a/src/views/Login/Login.vue
+++ b/src/views/Login/Login.vue
@@ -137,6 +137,8 @@
import closeEye from '@/assets/svgIcons/close_eye.svg?component';
import openEye from '@/assets/svgIcons/close_eye.svg?component';
+import * as accountServices from '@/services/api/Account';
+import SendVerificationCodeView from './components/SendVerificationCodeView.vue';
// import { useSettingStoreHook } from '@/store/modules/settings';
import Config from '@config/config';
@@ -175,16 +177,44 @@
return;
}
loading.value = true;
- await userStore.loginByUsername({
- userName: unref(user),
- userPassword: unref(pwd),
- clientId: 'goverend-admin-app-client',
- });
- loading.value = false;
- router.push({
- path: redirect.value || '/',
- query: otherQuery.value,
- });
+ let systemInfo = await getSystemInfo();
+ if (systemInfo.openTwoFactorLogin) {
+ let twoFactorLoginPasswordRes = await accountServices.twoFactorLoginPassword({
+ loginName: unref(user),
+ password: unref(pwd),
+ clientId: 'goverend-admin-app-client',
+ });
+ loading.value = false;
+ ElMessageBox({
+ title: `鍙戦�侀獙璇佺爜鍒�${twoFactorLoginPasswordRes.phoneNumber}`,
+ customClass: 'send-code-message-box',
+ //@ts-ignore
+ modalClass: 'send-code-message-box-model',
+ showConfirmButton: false,
+ message: h(SendVerificationCodeView, {
+ phoneNumber: twoFactorLoginPasswordRes.phoneNumber,
+ loginKey: twoFactorLoginPasswordRes.loginKey,
+ onSuccess: () => {
+ router.push({
+ path: redirect.value || '/',
+ query: otherQuery.value,
+ });
+ document.querySelector('.send-code-message-box-model').remove();
+ },
+ }),
+ });
+ } else {
+ await userStore.loginByUsername({
+ userName: unref(user),
+ userPassword: unref(pwd),
+ clientId: 'goverend-admin-app-client',
+ });
+ loading.value = false;
+ router.push({
+ path: redirect.value || '/',
+ query: otherQuery.value,
+ });
+ }
} catch (error) {
console.log(error);
// ElMessage({
@@ -195,6 +225,13 @@
};
const beforeLog = useDebounceFn(onLogin, 1000);
+async function getSystemInfo() {
+ let res = await accountServices.getSystemInfo({
+ showLoading: false,
+ });
+ return res;
+}
+
function onUserFocus() {
addClass(document.querySelector('.user'), 'focus');
}
--
Gitblit v1.9.1