|
2 | 2 |
|
3 | 3 | import { useEffect, useState } from 'react' |
4 | 4 | import { useRouter, useSearchParams } from 'next/navigation' |
5 | | -import { client } from '@/lib/auth-client' |
| 5 | +import { client, useSession } from '@/lib/auth-client' |
6 | 6 | import { env, isTruthy } from '@/lib/env' |
7 | 7 | import { createLogger } from '@/lib/logs/console/logger' |
8 | 8 |
|
@@ -34,6 +34,7 @@ export function useVerification({ |
34 | 34 | }: UseVerificationParams): UseVerificationReturn { |
35 | 35 | const router = useRouter() |
36 | 36 | const searchParams = useSearchParams() |
| 37 | + const { refetch: refetchSession } = useSession() |
37 | 38 | const [otp, setOtp] = useState('') |
38 | 39 | const [email, setEmail] = useState('') |
39 | 40 | const [isLoading, setIsLoading] = useState(false) |
@@ -136,16 +137,15 @@ export function useVerification({ |
136 | 137 | } |
137 | 138 | } |
138 | 139 |
|
139 | | - // Redirect to proper page after a short delay |
140 | 140 | setTimeout(() => { |
141 | 141 | if (isInviteFlow && redirectUrl) { |
142 | 142 | // For invitation flow, redirect to the invitation page |
143 | | - router.push(redirectUrl) |
| 143 | + window.location.href = redirectUrl |
144 | 144 | } else { |
145 | 145 | // Default redirect to dashboard |
146 | | - router.push('/workspace') |
| 146 | + window.location.href = '/workspace' |
147 | 147 | } |
148 | | - }, 2000) |
| 148 | + }, 1000) |
149 | 149 | } else { |
150 | 150 | logger.info('Setting invalid OTP state - API error response') |
151 | 151 | const message = 'Invalid verification code. Please check and try again.' |
@@ -233,7 +233,7 @@ export function useVerification({ |
233 | 233 | 'requiresEmailVerification=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT' |
234 | 234 |
|
235 | 235 | const timeoutId = setTimeout(() => { |
236 | | - router.push('/workspace') |
| 236 | + window.location.href = '/workspace' |
237 | 237 | }, 1000) |
238 | 238 |
|
239 | 239 | return () => clearTimeout(timeoutId) |
|
0 commit comments