diff --git a/web/src/components/auth/PasswordResetConfirm.js b/web/src/components/auth/PasswordResetConfirm.js
index dc69ccdc..e56a9b1a 100644
--- a/web/src/components/auth/PasswordResetConfirm.js
+++ b/web/src/components/auth/PasswordResetConfirm.js
@@ -15,12 +15,12 @@ const PasswordResetConfirm = () => {
token: '',
});
const { email, token } = inputs;
+ const isValidResetLink = email && token;
const [loading, setLoading] = useState(false);
const [disableButton, setDisableButton] = useState(false);
const [countdown, setCountdown] = useState(30);
const [newPassword, setNewPassword] = useState('');
-
const [searchParams, setSearchParams] = useSearchParams();
const logo = getLogo();
@@ -30,10 +30,10 @@ const PasswordResetConfirm = () => {
let token = searchParams.get('token');
let email = searchParams.get('email');
setInputs({
- token,
- email,
+ token: token || '',
+ email: email || '',
});
- }, []);
+ }, [searchParams]);
useEffect(() => {
let countdownInterval = null;
@@ -49,7 +49,10 @@ const PasswordResetConfirm = () => {
}, [disableButton, countdown]);
async function handleSubmit(e) {
- if (!email || !token) return;
+ if (!email || !token) {
+ showError(t('无效的重置链接,请重新发起密码重置请求'));
+ return;
+ }
setDisableButton(true);
setLoading(true);
const res = await API.post(`/api/user/reset`, {
@@ -94,6 +97,11 @@ const PasswordResetConfirm = () => {
{t('密码重置确认')}
+ {!isValidResetLink && (
+
+ {t('无效的重置链接,请重新发起密码重置请求')}
+
+ )}
{
name="email"
size="large"
className="!rounded-md"
- value={email}
- readOnly
+ value={email || ''}
+ disabled={true}
prefix={}
+ placeholder={email ? '' : t('等待获取邮箱信息...')}
/>
{newPassword && (
@@ -114,7 +123,7 @@ const PasswordResetConfirm = () => {
size="large"
className="!rounded-md"
value={newPassword}
- readOnly
+ disabled={true}
prefix={}
onClick={(e) => {
e.target.select();
@@ -133,9 +142,9 @@ const PasswordResetConfirm = () => {
size="large"
onClick={handleSubmit}
loading={loading}
- disabled={disableButton || newPassword}
+ disabled={disableButton || newPassword || !isValidResetLink}
>
- {newPassword ? t('密码重置完成') : t('提交')}
+ {newPassword ? t('密码重置完成') : t('确认重置密码')}
diff --git a/web/src/components/auth/PasswordResetForm.js b/web/src/components/auth/PasswordResetForm.js
index 6abdfaa5..4ff7882f 100644
--- a/web/src/components/auth/PasswordResetForm.js
+++ b/web/src/components/auth/PasswordResetForm.js
@@ -55,7 +55,10 @@ const PasswordResetForm = () => {
}
async function handleSubmit(e) {
- if (!email) return;
+ if (!email) {
+ showError(t('请输入邮箱地址'));
+ return;
+ }
if (turnstileEnabled && turnstileToken === '') {
showInfo(t('请稍后几秒重试,Turnstile 正在检查用户环境!'));
return;
diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json
index a3a05acd..a7201fe5 100644
--- a/web/src/i18n/locales/en.json
+++ b/web/src/i18n/locales/en.json
@@ -269,6 +269,10 @@
"密码重置确认": "Password Reset Confirmation",
"邮箱地址": "Email address",
"提交": "Submit",
+ "等待获取邮箱信息...": "Waiting to get email information...",
+ "确认重置密码": "Confirm Password Reset",
+ "无效的重置链接,请重新发起密码重置请求": "Invalid reset link, please initiate a new password reset request",
+ "请输入邮箱地址": "Please enter the email address",
"请稍后几秒重试": "Please retry in a few seconds",
"正在检查用户环境": "Checking user environment",
"重置邮件发送成功": "Reset mail sent successfully",