feat: 登录信息加密传输
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import type { FormInstance } from 'element-plus';
|
||||
import type {FormInstance} from 'element-plus';
|
||||
import {ElForm, ElFormItem, ElInput, ElMessage} from 'element-plus';
|
||||
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import {onMounted, ref, watch} from 'vue';
|
||||
|
||||
import { EasyFlowFormModal, EasyFlowInputPassword } from '@easyflow/common-ui';
|
||||
import {EasyFlowFormModal, EasyFlowInputPassword} from '@easyflow/common-ui';
|
||||
|
||||
import { ElForm, ElFormItem, ElInput, ElMessage } from 'element-plus';
|
||||
|
||||
import { api } from '#/api/request';
|
||||
import {getCredentialKeyApi} from '#/api';
|
||||
import {api} from '#/api/request';
|
||||
import DictSelect from '#/components/dict/DictSelect.vue';
|
||||
// import Cropper from '#/components/upload/Cropper.vue';
|
||||
import UploadAvatar from '#/components/upload/UploadAvatar.vue';
|
||||
import { $t } from '#/locales';
|
||||
import { isStrongPassword } from '#/utils/password-policy';
|
||||
import {$t} from '#/locales';
|
||||
import {encryptCredentialPayload} from '#/utils/credential-encryption';
|
||||
import {isStrongPassword} from '#/utils/password-policy';
|
||||
|
||||
const emit = defineEmits(['reload']);
|
||||
// vue
|
||||
@@ -107,26 +108,33 @@ function openDialog(row: any) {
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
function save() {
|
||||
saveForm.value?.validate((valid) => {
|
||||
saveForm.value?.validate(async (valid) => {
|
||||
if (valid) {
|
||||
btnLoading.value = true;
|
||||
const { confirmPassword: _confirmPassword, ...payload } = entity.value;
|
||||
api
|
||||
.post(
|
||||
try {
|
||||
const {
|
||||
confirmPassword: _confirmPassword,
|
||||
password,
|
||||
...payload
|
||||
} = entity.value;
|
||||
if (isAdd.value) {
|
||||
payload.passwordCredential = await encryptCredentialPayload(
|
||||
getCredentialKeyApi,
|
||||
{ password },
|
||||
);
|
||||
}
|
||||
const res = await api.post(
|
||||
isAdd.value ? 'api/v1/sysAccount/save' : 'api/v1/sysAccount/update',
|
||||
payload,
|
||||
)
|
||||
.then((res) => {
|
||||
btnLoading.value = false;
|
||||
if (res.errorCode === 0) {
|
||||
ElMessage.success(res.message);
|
||||
emit('reload');
|
||||
closeDialog();
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
btnLoading.value = false;
|
||||
});
|
||||
);
|
||||
if (res.errorCode === 0) {
|
||||
ElMessage.success(res.message);
|
||||
emit('reload');
|
||||
closeDialog();
|
||||
}
|
||||
} finally {
|
||||
btnLoading.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user