import { initialPasswordAtom, userAtom } from '@/atoms/user'; import SealInput from '@/components/seal-form/seal-input'; import { PasswordReg } from '@/config'; import { CRYPT_TEXT } from '@/utils/localstore/index'; import { GlobalOutlined, LockOutlined } from '@ant-design/icons'; import { SelectLang, useIntl } from '@umijs/max'; import { Button, Form, message } from 'antd'; import CryptoJS from 'crypto-js'; import { useAtom } from 'jotai'; import { updatePassword } from '../apis'; import { checkDefaultPage } from '../utils'; const PasswordForm: React.FC = () => { const intl = useIntl(); const [form] = Form.useForm(); const [userInfo, setUserInfo] = useAtom(userAtom); const [initialPassword, setInitialPassword] = useAtom(initialPasswordAtom); const gotoDefaultPage = async (userInfo: any) => { checkDefaultPage(userInfo, false); }; 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) => { try { await updatePassword({ new_password: values.new_password, current_password: decryptPassword(initialPassword) }); await setUserInfo({ ...userInfo, require_password_change: false }); setInitialPassword(''); gotoDefaultPage(userInfo); message.success(intl.formatMessage({ id: 'common.message.success' })); } catch (error) { console.log('error====', error); } }; return (