From 28297aa9bac0f3c33f6c1fb51f03afdf77fd065f Mon Sep 17 00:00:00 2001
From: wangxiaoshuang <825034831@qq.com>
Date: Wed, 12 Jun 2024 11:34:31 +0800
Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=8F=8A=E9=94=81=E5=AE=9A?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=8C=E6=AC=A1=E9=AA=8C=E8=AF=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/user.js | 18 ++
src/components/MFA/fun.js | 26 +++
src/components/MFA/index.js | 7 +
src/components/MFA/index.vue | 172 +++++++++++++++
src/main.js | 46 ++--
src/store/modules/user.js | 11 +-
src/views/login/index.vue | 394 +++++++++++++++++++---------------
src/views/recompose/index.vue | 2 +-
8 files changed, 490 insertions(+), 186 deletions(-)
create mode 100644 src/components/MFA/fun.js
create mode 100644 src/components/MFA/index.js
create mode 100644 src/components/MFA/index.vue
diff --git a/src/api/user.js b/src/api/user.js
index 92fe16f7..67027318 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -167,3 +167,21 @@ export function getTrialUserList(params) {
params
})
}
+
+// 验证MFA邮件
+export function verifyMFACode(params) {
+ return request({
+ url: `/User/verifyMFACode`,
+ method: 'post',
+ params
+ })
+}
+
+// 发送MFA邮件
+export function sendMFAEmail(params) {
+ return request({
+ url: `/User/sendMFAEmail`,
+ method: 'post',
+ params
+ })
+}
diff --git a/src/components/MFA/fun.js b/src/components/MFA/fun.js
new file mode 100644
index 00000000..f8192fe6
--- /dev/null
+++ b/src/components/MFA/fun.js
@@ -0,0 +1,26 @@
+import Vue from "vue";
+import MFACOMP from "./index.vue";
+
+const MFAConstructor = Vue.extend(MFACOMP);
+
+const MFA = options => {
+ const { UserId, username, EMail, callBack, cancelBack, status = 'login' } = options;
+ if (!UserId) throw `UserId is requred.but ${UserId}`
+ const id = `MFA${new Date().getTime()}`;
+ const instance = new MFAConstructor();
+ instance.id = id;
+ instance.vm = instance.$mount();
+ if (instance.vm.visible) return;
+ document.body.appendChild(instance.vm.$el);
+ instance.vm.open({ UserId, username, EMail, status });
+ instance.vm.$on("success", (Id) => {
+ if (callBack) callBack(Id)
+ });
+ instance.vm.$on("closed", () => {
+ if (cancelBack) cancelBack();
+ document.body.removeChild(instance.vm.$el);
+ instance.vm.$destroy();
+ });
+ return instance.vm;
+}
+export default MFA;
\ No newline at end of file
diff --git a/src/components/MFA/index.js b/src/components/MFA/index.js
new file mode 100644
index 00000000..df785460
--- /dev/null
+++ b/src/components/MFA/index.js
@@ -0,0 +1,7 @@
+import MFACOMP from "./index.vue";
+import MFA from "./fun";
+
+export default Vue => {
+ Vue.component(MFACOMP.name, MFACOMP);
+ Vue.prototype.$MFA = MFA;
+};
\ No newline at end of file
diff --git a/src/components/MFA/index.vue b/src/components/MFA/index.vue
new file mode 100644
index 00000000..b8089037
--- /dev/null
+++ b/src/components/MFA/index.vue
@@ -0,0 +1,172 @@
+
+
+
+
+ {{ status === "login" ? $t("mfa:title") : $t("mfa:lock:title") }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ flag ? `${second}s` : $t("mfa:form:sendMFACode") }}
+
+
+
+
+
+ {{ $t("mfa:button:cancel") }}
+
+
+
+ {{
+ status === "login"
+ ? $t("mfa:button:save")
+ : $t("mfa:lock:button:save")
+ }}
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index cc88f482..2c31c761 100644
--- a/src/main.js
+++ b/src/main.js
@@ -4,6 +4,7 @@ import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElementUI, { MessageBox } from 'element-ui'
import { getBasicDataAllSelect, getFrontInternationalizationList } from '@/api/dictionary/dictionary'
+import { sendMFAEmail } from "@/api/user.js";
import { resetReadingRestTime } from '@/api/trials/reading'
// import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/theme-blue/index.css' // 浅绿色主题
@@ -58,6 +59,8 @@ import upload from '@/components/element-ui/upload'
Vue.use(upload)
import Preview from '@/components/Preview/index'
Vue.use(Preview)
+import MFA from '@/components/MFA/index'
+Vue.use(MFA)
import adaptive from '@/directive/adaptive/index'
// 表格自适应指令
Vue.use(adaptive)
@@ -406,24 +409,37 @@ async function VueInit() {
}
var my_username = zzSessionStorage.getItem('my_username')
var my_password = zzSessionStorage.getItem('my_password')
+ let my_userid = zzSessionStorage.getItem('userId')
+ let my_EMail = zzSessionStorage.getItem('my_EMail')
if (md5(_vm.unlock.my_password) === my_password && my_username === _vm.unlock.my_username) {
resetReadingRestTime().then(() => {
})
- _vm.$message.success(lang === 'zh' ? '解锁成功,请继续操作' : 'Unlocked successfully. Please continue operation.')
- _vm.unlock = {
- my_username: null,
- my_password: null
- }
- isOpen = false
- count = 0;
- isLock = null
- zzSessionStorage.removeItem('isLock')
- localStorage.setItem('count', '0')
- document.querySelector('#my_username').value = null
- document.querySelector('#my_password').value = null
- setTimeout(() => {
- done()
- }, 500)
+ sendMFAEmail({ UserId: my_userid }).then((res) => {
+ done();
+ Vue.prototype.$MFA({
+ status: "lock",
+ UserId: my_userid,
+ EMail: my_EMail,
+ username: my_username,
+ callBack: () => {
+ _vm.$message.success(lang === 'zh' ? '解锁成功,请继续操作' : 'Unlocked successfully. Please continue operation.')
+ _vm.unlock = {
+ my_username: null,
+ my_password: null
+ }
+ isOpen = false
+ count = 0;
+ isLock = null
+ zzSessionStorage.removeItem('isLock')
+ localStorage.setItem('count', '0')
+ document.querySelector('#my_username').value = null
+ document.querySelector('#my_password').value = null
+ setTimeout(() => {
+ done()
+ }, 500)
+ },
+ })
+ })
} else {
// console.log(111)
_vm.$message.error(lang === 'zh' ? '请输入正确用户名密码' : 'Please enter the correct password.')
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index 21de24d4..70ef429f 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -83,13 +83,20 @@ const actions = {
},
// user login
login({ commit }, userInfo) {
- const { username, password } = userInfo
+ const { username, password, UserId } = userInfo
return new Promise((resolve, reject) => {
- login({ UserName: username.trim(), Password: md5(password) }).then(async response => {
+ let data = {
+ UserName: username.trim(), Password: md5(password)
+ }
+ if (UserId) {
+ data.UserId = UserId;
+ }
+ login(data).then(async response => {
if (response.IsSuccess) {
zzSessionStorage.removeItem('lastWorkbench')
zzSessionStorage.setItem('my_username', username.trim())
zzSessionStorage.setItem('my_password', md5(password))
+ zzSessionStorage.setItem('my_EMail', response.Result.BasicInfo.EMail)
const data = response.Result
if (data.BasicInfo.IsFirstAdd || data.BasicInfo.LoginState === 1) {
try {
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index ad164eeb..27c39894 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -6,17 +6,17 @@
-

+
-
{{ $t('login:title:system') }}
+
{{ $t("login:title:system") }}
@@ -50,7 +54,11 @@
@@ -69,101 +77,130 @@
@keyup.enter.native="handleLogin"
/>
-
+
- {{ $t('login:button:login') }}
+ {{ $t("login:button:login") }}
-
+
-
- {{ $t('login:button:forgetPassword') }}
+
+ {{ $t("login:button:forgetPassword") }}
-
+
-
-
关于
-
- IRC Imaging System
-
-
- V1.5.0.001
-
+
+
关于
+
IRC Imaging System
+
V1.5.0.001
- Copyright © {{ new Date().getFullYear() }} 上海展影医疗科技有限公司 版权所有
+ Copyright © {{ new Date().getFullYear() }} 上海展影医疗科技有限公司
+ 版权所有
- Copyright © {{ new Date().getFullYear() }} Shanghai Extensive Imaging Inc.
+ Copyright © {{ new Date().getFullYear() }} Shanghai Extensive Imaging
+ Inc.
-

+
diff --git a/src/views/recompose/index.vue b/src/views/recompose/index.vue
index 03d62875..edc686f4 100644
--- a/src/views/recompose/index.vue
+++ b/src/views/recompose/index.vue
@@ -146,7 +146,7 @@ export default {
}