File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/app/(auth)/forgot-password Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { useSessionStore } from "@/state/session";
2121import { Captcha } from "@/components/captcha" ;
2222import { forgotPasswordSchema } from "@/schemas/forgot-password.schema" ;
2323import { useConfigStore } from "@/state/config" ;
24+ import { useEffect } from "react" ;
2425
2526type ForgotPasswordSchema = z . infer < typeof forgotPasswordSchema > ;
2627
@@ -33,6 +34,12 @@ export default function ForgotPasswordClientComponent() {
3334 resolver : zodResolver ( forgotPasswordSchema ) ,
3435 } ) ;
3536
37+ useEffect ( ( ) => {
38+ if ( session ?. user ?. email ) {
39+ form . setValue ( 'email' , session ?. user ?. email ) ;
40+ }
41+ } , [ form , session ?. user ?. email ] ) ;
42+
3643 const captchaToken = useWatch ( { control : form . control , name : 'captchaToken' } )
3744
3845 const { execute : sendResetLink , isSuccess } = useServerAction ( forgotPasswordAction , {
@@ -50,7 +57,10 @@ export default function ForgotPasswordClientComponent() {
5057 } ) ;
5158
5259 const onSubmit = async ( data : ForgotPasswordSchema ) => {
53- sendResetLink ( data ) ;
60+ sendResetLink ( {
61+ ...data ,
62+ email : data . email ?? session ?. user ?. email ,
63+ } ) ;
5464 } ;
5565
5666 if ( isSuccess ) {
You can’t perform that action at this time.
0 commit comments