From 25cc28e03bc58c0f18ee91ba9145103764576b4f Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Wed, 19 Nov 2025 16:15:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=85=A8=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E9=82=AE=E7=AE=B1=E7=99=BB=E5=BD=95=E4=BB=A3=E7=A0=81=20?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=20registerWithEmail=20=E6=96=B9=E6=B3=95=20?= =?UTF-8?q?=20=20=20=20=20=E7=A7=BB=E9=99=A4=20sendEmailCode=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=20=20=20=20=20=20=E5=B7=B2=E4=BB=8E=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E4=B8=AD=E7=A7=BB=E9=99=A4=20registerWithEma?= =?UTF-8?q?il=20=E5=92=8C=20sendEmailCode=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contexts/AuthContext.js | 88 ------------------------------------- 1 file changed, 88 deletions(-) diff --git a/src/contexts/AuthContext.js b/src/contexts/AuthContext.js index 38123ff1..315c05c2 100755 --- a/src/contexts/AuthContext.js +++ b/src/contexts/AuthContext.js @@ -308,63 +308,6 @@ export const AuthProvider = ({ children }) => { } }; - // 邮箱注册 - const registerWithEmail = async (email, code, username, password) => { - try { - setIsLoading(true); - - const response = await fetch(`/api/auth/register/email`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - credentials: 'include', - body: JSON.stringify({ - email, - code, - username, - password - }) - }); - - const data = await response.json(); - - if (!response.ok || !data.success) { - throw new Error(data.error || '注册失败'); - } - - // 注册成功后自动登录 - setUser(data.user); - setIsAuthenticated(true); - - // ❌ 过时的追踪代码已移除(新代码在组件中使用 useAuthEvents 追踪) - // 正确的事件追踪应在调用此方法的组件中使用 authEvents.trackLoginSuccess() - // 事件名:'User Signed Up'(不是 'user_registered') - // 属性名:login_method(不是 method) - - toast({ - title: "注册成功", - description: "欢迎加入价值前沿!", - status: "success", - duration: 3000, - isClosable: true, - }); - - // ⚡ 注册成功后显示欢迎引导(延迟2秒) - setTimeout(() => { - showWelcomeGuide(); - }, 2000); - - return { success: true }; - - } catch (error) { - logger.error('AuthContext', 'registerWithEmail', error); - return { success: false, error: error.message }; - } finally { - setIsLoading(false); - } - }; - // 发送手机验证码 const sendSmsCode = async (phone) => { try { @@ -394,35 +337,6 @@ export const AuthProvider = ({ children }) => { } }; - // 发送邮箱验证码 - const sendEmailCode = async (email) => { - try { - const response = await fetch(`/api/auth/send-email-code`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - credentials: 'include', - body: JSON.stringify({ email }) - }); - - const data = await response.json(); - - if (!response.ok) { - throw new Error(data.error || '发送失败'); - } - - // ❌ 移除成功 toast - logger.info('AuthContext', '邮箱验证码已发送', { email: email.substring(0, 3) + '***@***' }); - return { success: true }; - - } catch (error) { - // ❌ 移除错误 toast - logger.error('AuthContext', 'sendEmailCode', error); - return { success: false, error: error.message }; - } - }; - // 登出方法 const logout = async () => { try { @@ -483,9 +397,7 @@ export const AuthProvider = ({ children }) => { updateUser, login, registerWithPhone, - registerWithEmail, sendSmsCode, - sendEmailCode, logout, hasRole, refreshSession,