chore: shortcut table

This commit is contained in:
jialin
2024-08-26 19:12:08 +08:00
parent 84bed59f21
commit 2b1f5d38e1
16 changed files with 304 additions and 32 deletions
+2 -1
View File
@@ -125,7 +125,6 @@ const LoginForm = () => {
});
const userInfo = await fetchUserInfo();
setUserInfo(userInfo);
setInitialPassword(values.password);
if (values.autoLogin) {
await callRememberMe(values);
} else {
@@ -133,6 +132,8 @@ const LoginForm = () => {
}
if (!userInfo?.require_password_change) {
gotoDefaultPage(userInfo);
} else {
setInitialPassword(encryptPassword(values.password));
}
} catch (error) {
// to do something
+10 -1
View File
@@ -4,9 +4,12 @@ import { PasswordReg } from '@/config';
import { GlobalOutlined, LockOutlined } from '@ant-design/icons';
import { SelectLang, history, useIntl } from '@umijs/max';
import { Button, Form, message } from 'antd';
import CryptoJS from 'crypto-js';
import { useAtom } from 'jotai';
import { updatePassword } from '../apis';
const CRYPT_TEXT = 'seal';
const PasswordForm: React.FC = () => {
const intl = useIntl();
const [form] = Form.useForm();
@@ -19,12 +22,18 @@ const PasswordForm: React.FC = () => {
history.push(pathname);
};
const decryptPassword = (password: string) => {
const bytes = CryptoJS.AES?.decrypt?.(password, CRYPT_TEXT);
const res = bytes.toString(CryptoJS.enc.Utf8);
return res;
};
const handleSubmit = async (values: any) => {
console.log('values', values, form);
try {
await updatePassword({
new_password: values.new_password,
current_password: initialPassword
current_password: decryptPassword(initialPassword)
});
await setUserInfo({