Skip to content

Let's use AI to Earn!

fix(web): Forgot password function not working (#334)

布莱恩·奥夫托·杰森张40070a21bb63
diff --git a/project/web/src/api/apiReq.ts b/project/web/src/api/apiReq.ts
index 67e9ecc5..7ca12656 100644
--- a/project/web/src/api/apiReq.ts
+++ b/project/web/src/api/apiReq.ts
@@ -84,7 +84,7 @@ export function resetPasswordApi(data: {
password: string
}) {
const hash = md5(data.password)
- return http.post<LoginResponse>('login/repassword/mail', {
+ return http.put<LoginResponse>('login/repassword/mail', {
...data,
password: hash,
})
diff --git a/project/web/src/app/[lng]/forgot-password/page.tsx b/project/web/src/app/[lng]/forgot-password/page.tsx
index 503a4989..ca2452a4 100644
--- a/project/web/src/app/[lng]/forgot-password/page.tsx
+++ b/project/web/src/app/[lng]/forgot-password/page.tsx
@@ -16,13 +16,13 @@ export default function ForgotPasswordPage() {
const [isModalOpen, setIsModalOpen] = useState(false)
const [resetForm] = Form.useForm()
- // 处理Modal关闭
+ // Handle modal close
const handleModalClose = () => {
setIsModalOpen(false)
resetForm.resetFields()
}
- // 处理发送重置密码邮件
+ // Handle send reset password email
const handleSubmit = async (values: { mail: string }) => {
try {
setLoading(true)
@@ -41,7 +41,7 @@ export default function ForgotPasswordPage() {
}
}
- // 处理重置密码
+ // Handle reset password
const handleResetPassword = async (values: { code: string, password: string }) => {
try {
setLoading(true)
diff --git a/project/web/src/app/[lng]/login/page.tsx b/project/web/src/app/[lng]/login/page.tsx
index 3f0e71d5..c89f75e4 100644
--- a/project/web/src/app/[lng]/login/page.tsx
+++ b/project/web/src/app/[lng]/login/page.tsx
@@ -5,7 +5,6 @@ import { Button, Form, Input, message, Modal } from 'antd'
import Link from 'next/link'
import { useRouter } from 'next/navigation'
import { useEffect, useState } from 'react'
-import { FcGoogle } from 'react-icons/fc'
import {
checkRegistStatusApi,
getRegistUrlApi,
@@ -42,14 +41,14 @@ export default function LoginPage() {
if (response.code === 0) {
if (response.data.type === 'regist') {
- // 用户未注册,显示弹窗提示,并设置表单的默认密码值
+ // User not registered, show modal prompt and set default password value for form
setRegistCode(response.data.code || '')
- form.setFieldsValue({ password }) // 设置密码字段的默认值
+ form.setFieldsValue({ password }) // Set default value for password field
setIsModalOpen(true)
setIsChecking(true)
}
else if (response.data.token) {
- // 登录成功
+ // Login successful
setToken(response.data.token)
if (response.data.userInfo) {
setUserInfo(response.data.userInfo)
@@ -85,10 +84,10 @@ export default function LoginPage() {
}
if (response.code === 0 && response.data.token) {
- // 注册成功
+ // Registration successful
setIsActivating(false)
setIsModalOpen(false)
- form.resetFields() // 重置表单
+ form.resetFields() // Reset form
setToken(response.data.token)
if (response.data.userInfo) {
setUserInfo(response.data.userInfo)
@@ -107,7 +106,7 @@ export default function LoginPage() {
}
}
- // 组件卸载时清除定时器
+ // Clear timer when component unmounts
useEffect(() => {
return () => {
if (activationTimer) {
@@ -135,7 +134,7 @@ export default function LoginPage() {
if (response.code === 0) {
if (response.data.type === 'login') {
- // 直接登录成功
+ // Direct login successful
setToken(response.data.token)
if (response.data.userInfo) {
setUserInfo(response.data.userInfo)
@@ -219,7 +218,7 @@ export default function LoginPage() {
setIsModalOpen(false)
setIsChecking(false)
setIsActivating(false)
- form.resetFields() // 重置表单
+ form.resetFields() // Reset form
if (activationTimer) {
clearInterval(activationTimer)
}