chore: shortcut table
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user