|
|
|
|
@ -6,7 +6,6 @@ import { updatePassword } from '@/pages/login/apis';
|
|
|
|
|
import { PageContainer } from '@ant-design/pro-components';
|
|
|
|
|
import { useIntl } from '@umijs/max';
|
|
|
|
|
import { Form, message } from 'antd';
|
|
|
|
|
import { StrictMode } from 'react';
|
|
|
|
|
|
|
|
|
|
interface ProfileProps {
|
|
|
|
|
username?: string;
|
|
|
|
|
@ -35,99 +34,97 @@ const Profile: React.FC = () => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<StrictMode>
|
|
|
|
|
<PageContainer
|
|
|
|
|
ghost
|
|
|
|
|
header={{
|
|
|
|
|
title: intl.formatMessage({ id: 'users.form.updatepassword' })
|
|
|
|
|
}}
|
|
|
|
|
extra={[]}
|
|
|
|
|
<PageContainer
|
|
|
|
|
ghost
|
|
|
|
|
header={{
|
|
|
|
|
title: intl.formatMessage({ id: 'users.form.updatepassword' })
|
|
|
|
|
}}
|
|
|
|
|
extra={[]}
|
|
|
|
|
>
|
|
|
|
|
<Form
|
|
|
|
|
style={{ width: '524px' }}
|
|
|
|
|
name="profileForm"
|
|
|
|
|
form={form}
|
|
|
|
|
onFinish={handleOnFinish}
|
|
|
|
|
onFinishFailed={handleOnFinishFailed}
|
|
|
|
|
>
|
|
|
|
|
<Form
|
|
|
|
|
style={{ width: '524px' }}
|
|
|
|
|
name="profileForm"
|
|
|
|
|
form={form}
|
|
|
|
|
onFinish={handleOnFinish}
|
|
|
|
|
onFinishFailed={handleOnFinishFailed}
|
|
|
|
|
>
|
|
|
|
|
<Form.Item<ProfileProps>
|
|
|
|
|
name="current_password"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: intl.formatMessage(
|
|
|
|
|
{ id: 'common.form.rule.input' },
|
|
|
|
|
{
|
|
|
|
|
name: intl.formatMessage({
|
|
|
|
|
id: 'users.form.currentpassword'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<SealInput.Password
|
|
|
|
|
label={intl.formatMessage({ id: 'users.form.currentpassword' })}
|
|
|
|
|
required
|
|
|
|
|
style={{ width: INPUT_WIDTH.default }}
|
|
|
|
|
></SealInput.Password>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item<ProfileProps>
|
|
|
|
|
name="new_password"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
pattern: PasswordReg,
|
|
|
|
|
message: intl.formatMessage({
|
|
|
|
|
id: 'users.form.rule.password'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<SealInput.Password
|
|
|
|
|
label={intl.formatMessage({ id: 'users.form.newpassword' })}
|
|
|
|
|
required
|
|
|
|
|
style={{ width: INPUT_WIDTH.default }}
|
|
|
|
|
></SealInput.Password>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
name="confirm_password"
|
|
|
|
|
dependencies={['new_password']}
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: intl.formatMessage({
|
|
|
|
|
id: 'users.password.confirm.empty'
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
({ getFieldValue }) => ({
|
|
|
|
|
validator(_, value) {
|
|
|
|
|
if (!value || getFieldValue('new_password') === value) {
|
|
|
|
|
return Promise.resolve();
|
|
|
|
|
}
|
|
|
|
|
return Promise.reject(
|
|
|
|
|
new Error(
|
|
|
|
|
intl.formatMessage({ id: 'users.password.confirm.error' })
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
<Form.Item<ProfileProps>
|
|
|
|
|
name="current_password"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: intl.formatMessage(
|
|
|
|
|
{ id: 'common.form.rule.input' },
|
|
|
|
|
{
|
|
|
|
|
name: intl.formatMessage({
|
|
|
|
|
id: 'users.form.currentpassword'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<SealInput.Password
|
|
|
|
|
label={intl.formatMessage({ id: 'users.form.currentpassword' })}
|
|
|
|
|
required
|
|
|
|
|
style={{ width: INPUT_WIDTH.default }}
|
|
|
|
|
></SealInput.Password>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item<ProfileProps>
|
|
|
|
|
name="new_password"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
pattern: PasswordReg,
|
|
|
|
|
message: intl.formatMessage({
|
|
|
|
|
id: 'users.form.rule.password'
|
|
|
|
|
})
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<SealInput.Password
|
|
|
|
|
required={true}
|
|
|
|
|
style={{ width: INPUT_WIDTH.default }}
|
|
|
|
|
label={intl.formatMessage({ id: 'users.password.confirm' })}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<FormButtons
|
|
|
|
|
htmlType="submit"
|
|
|
|
|
onCancel={handleCancel}
|
|
|
|
|
showCancel={false}
|
|
|
|
|
></FormButtons>
|
|
|
|
|
</Form>
|
|
|
|
|
</PageContainer>
|
|
|
|
|
</StrictMode>
|
|
|
|
|
}
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<SealInput.Password
|
|
|
|
|
label={intl.formatMessage({ id: 'users.form.newpassword' })}
|
|
|
|
|
required
|
|
|
|
|
style={{ width: INPUT_WIDTH.default }}
|
|
|
|
|
></SealInput.Password>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
name="confirm_password"
|
|
|
|
|
dependencies={['new_password']}
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: intl.formatMessage({
|
|
|
|
|
id: 'users.password.confirm.empty'
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
({ getFieldValue }) => ({
|
|
|
|
|
validator(_, value) {
|
|
|
|
|
if (!value || getFieldValue('new_password') === value) {
|
|
|
|
|
return Promise.resolve();
|
|
|
|
|
}
|
|
|
|
|
return Promise.reject(
|
|
|
|
|
new Error(
|
|
|
|
|
intl.formatMessage({ id: 'users.password.confirm.error' })
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<SealInput.Password
|
|
|
|
|
required={true}
|
|
|
|
|
style={{ width: INPUT_WIDTH.default }}
|
|
|
|
|
label={intl.formatMessage({ id: 'users.password.confirm' })}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<FormButtons
|
|
|
|
|
htmlType="submit"
|
|
|
|
|
onCancel={handleCancel}
|
|
|
|
|
showCancel={false}
|
|
|
|
|
></FormButtons>
|
|
|
|
|
</Form>
|
|
|
|
|
</PageContainer>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|