Repository: supabase/supabase
File: apps/studio/components/interfaces/SignIn/ForgotPasswordWizard.tsx (TypeScript)

Code before:
  })

  const onCodeEntered: SubmitHandler<CodeFormData> = async (data) => {
    setIsLoading(true)
    const {
      data: { user },
      error,
    } = await auth.verifyOtp({ email, token: data.code, type: 'recovery' })

    // This fixes a race condition where the user is redirected to the reset password page without the session being set
    // which causes the user to be redirected to /sign-in page even though he's signed in
    await new Promise((resolve) => setTimeout(resolve, 1000))

    if (error) {
      setIsLoading(false)
      toast.error(`Failed to verify code: ${error.message}`)
    } else {
      if (user?.factors?.length) {
        await router.push({
          pathname: '/forgot-password-mfa',
          query: router.query,
        })
      } else {
        await router.push({
          pathname: '/reset-password',
          query: { ...router.query, type: 'recovery' },
        })
      }
    }
  }

  return (
    <Form_Shadcn_ {...codeForm}>
      <form
        id="code-input-form"
        className="flex flex-col pt-4 space-y-4"
        onSubmit={codeForm.handleSubmit(onCodeEntered)}
      >
        <Admonition
          type="default"
          title="Check your email for a reset code"
          description="You'll receive an email if an account associated with the email address exists"
        />
        <FormField_Shadcn_
          control={codeForm.control}
          name="code"
          render={({ field }) => (
            <FormItemLayout label="Code">
              <FormControl_Shadcn_>
                <Input_Shadcn_
                  {...field}

Review comment (suggestion):
guessing we should be doing this change in `SignInMfaForm` as well?

[edit] ignore this one - will be doing [this](https://github.com/supabase/supabase/pull/43085#discussion_r2857064419)

Code after:

  const onCodeEntered: SubmitHandler<CodeFormData> = async (data) => {
    setIsLoading(true)
    const {
      data: { user },
      error,
    } = await auth.verifyOtp({ email, token: data.code, type: 'recovery' })

    // This fixes a race condition where the user is redirected to the reset password page without the session being set
    // which causes the user to be redirected to /sign-in page even though he's signed in
    await new Promise((resolve) => setTimeout(resolve, 1000))

    if (error) {
      setIsLoading(false)
      toast.error(`Failed to verify code: ${error.message}`)
    } else {
      if (user?.factors?.length) {
        await router.push({
          pathname: '/forgot-password-mfa',
          query: router.query,
        })
      } else {
        await router.push({
          pathname: '/reset-password',
          query: router.query,
        })
      }
    }
  }

  return (
    <Form_Shadcn_ {...codeForm}>
      <form
        id="code-input-form"
        className="flex flex-col pt-4 space-y-4"
        onSubmit={codeForm.handleSubmit(onCodeEntered)}
      >
        <Admonition
          type="default"
          title="Check your email for a reset code"
          description="You'll receive an email if an account associated with the email address exists"
        />
        <FormField_Shadcn_
          control={codeForm.control}
          name="code"
          render={({ field }) => (
            <FormItemLayout label="Code">
              <FormControl_Shadcn_>
                <Input_Shadcn_
                  {...field}
                  placeholder="123456"