diff --git a/app/[lng]/request-reset/page.tsx b/app/[lng]/request-reset/page.tsx index 5ab3eb2..71ce67b 100644 --- a/app/[lng]/request-reset/page.tsx +++ b/app/[lng]/request-reset/page.tsx @@ -1,16 +1,16 @@ +"use client"; import { useState } from "react"; -import { supabase } from "@/utils/supabaseClient"; +import { createClient } from "@/utils/supabase/client"; const RequestResetPassword = () => { + const supabase = createClient(); + const [email, setEmail] = useState(""); const handleResetPassword = async () => { - const { data, error } = await supabase.auth.api.resetPasswordForEmail( - email, - { - redirectTo: `${window.location.origin}/reset-password`, // 确保这个URL是你重置密码页面的地址 - } - ); + const { data, error } = await supabase.auth.resetPasswordForEmail(email, { + redirectTo: `${window.location.origin}/reset-password`, // 确保这个URL是你重置密码页面的地址 + }); if (error) { alert("Error sending password reset email: " + error.message); diff --git a/app/[lng]/reset-password/page.tsx b/app/[lng]/reset-password/page.tsx index 903012b..f7568f5 100644 --- a/app/[lng]/reset-password/page.tsx +++ b/app/[lng]/reset-password/page.tsx @@ -1,8 +1,11 @@ +"use client"; import { useState } from "react"; -import { supabase } from "@/utils/supabaseClient"; +import { createClient } from "@/utils/supabase/client"; import { useRouter } from "next/router"; const ResetPassword = () => { + const supabase = createClient(); + const [newPassword, setNewPassword] = useState(""); const router = useRouter(); const { access_token } = router.query; // 获取URL中的access_token参数 @@ -13,7 +16,7 @@ const ResetPassword = () => { return; } - const { error } = await supabase.auth.api.updateUser(access_token, { + const { error } = await supabase.auth.updateUser(access_token, { password: newPassword, });