Skip to content

An AI-powered search engine with a generative UI

fix: update redirect paths in sign-up and update-password forms

Yoshiki Miurac57a022a9e47
diff --git a/components/sign-up-form.tsx b/components/sign-up-form.tsx
index cce47b99..351c6e50 100644
--- a/components/sign-up-form.tsx
+++ b/components/sign-up-form.tsx
@@ -1,22 +1,25 @@
'use client'
-import { cn } from '@/lib/utils/index'
-import { createClient } from '@/lib/supabase/client'
import { Button } from '@/components/ui/button'
import {
Card,
CardContent,
CardDescription,
CardHeader,
- CardTitle,
+ CardTitle
} from '@/components/ui/card'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
+import { createClient } from '@/lib/supabase/client'
+import { cn } from '@/lib/utils/index'
import Link from 'next/link'
import { useRouter } from 'next/navigation'
import { useState } from 'react'
-export function SignUpForm({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) {
+export function SignUpForm({
+ className,
+ ...props
+}: React.ComponentPropsWithoutRef<'div'>) {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const [repeatPassword, setRepeatPassword] = useState('')
@@ -41,8 +44,8 @@ export function SignUpForm({ className, ...props }: React.ComponentPropsWithoutR
email,
password,
options: {
- emailRedirectTo: `${window.location.origin}/protected`,
- },
+ emailRedirectTo: `${window.location.origin}/`
+ }
})
if (error) throw error
router.push('/auth/sign-up-success')
@@ -71,7 +74,7 @@ export function SignUpForm({ className, ...props }: React.ComponentPropsWithoutR
placeholder="[email protected]"
required
value={email}
- onChange={(e) => setEmail(e.target.value)}
+ onChange={e => setEmail(e.target.value)}
/>
</div>
<div className="grid gap-2">
@@ -83,7 +86,7 @@ export function SignUpForm({ className, ...props }: React.ComponentPropsWithoutR
type="password"
required
value={password}
- onChange={(e) => setPassword(e.target.value)}
+ onChange={e => setPassword(e.target.value)}
/>
</div>
<div className="grid gap-2">
@@ -95,7 +98,7 @@ export function SignUpForm({ className, ...props }: React.ComponentPropsWithoutR
type="password"
required
value={repeatPassword}
- onChange={(e) => setRepeatPassword(e.target.value)}
+ onChange={e => setRepeatPassword(e.target.value)}
/>
</div>
{error && <p className="text-sm text-red-500">{error}</p>}
diff --git a/components/update-password-form.tsx b/components/update-password-form.tsx
index fab8fc32..b82827d6 100644
--- a/components/update-password-form.tsx
+++ b/components/update-password-form.tsx
@@ -1,21 +1,24 @@
'use client'
-import { cn } from '@/lib/utils/index'
-import { createClient } from '@/lib/supabase/client'
import { Button } from '@/components/ui/button'
import {
Card,
CardContent,
CardDescription,
CardHeader,
- CardTitle,
+ CardTitle
} from '@/components/ui/card'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
+import { createClient } from '@/lib/supabase/client'
+import { cn } from '@/lib/utils/index'
import { useRouter } from 'next/navigation'
import { useState } from 'react'
-export function UpdatePasswordForm({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) {
+export function UpdatePasswordForm({
+ className,
+ ...props
+}: React.ComponentPropsWithoutRef<'div'>) {
const [password, setPassword] = useState('')
const [error, setError] = useState<string | null>(null)
const [isLoading, setIsLoading] = useState(false)
@@ -30,8 +33,9 @@ export function UpdatePasswordForm({ className, ...props }: React.ComponentProps
try {
const { error } = await supabase.auth.updateUser({ password })
if (error) throw error
- // Update this route to redirect to an authenticated route. The user already has an active session.
- router.push('/protected')
+ // Redirect to root and refresh to ensure server components get updated session.
+ router.push('/')
+ router.refresh()
} catch (error: unknown) {
setError(error instanceof Error ? error.message : 'An error occurred')
} finally {
@@ -44,7 +48,9 @@ export function UpdatePasswordForm({ className, ...props }: React.ComponentProps
<Card>
<CardHeader>
<CardTitle className="text-2xl">Reset Your Password</CardTitle>
- <CardDescription>Please enter your new password below.</CardDescription>
+ <CardDescription>
+ Please enter your new password below.
+ </CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={handleForgotPassword}>
@@ -57,7 +63,7 @@ export function UpdatePasswordForm({ className, ...props }: React.ComponentProps
placeholder="New password"
required
value={password}
- onChange={(e) => setPassword(e.target.value)}
+ onChange={e => setPassword(e.target.value)}
/>
</div>
{error && <p className="text-sm text-red-500">{error}</p>}