refactor: update routing logic to redirect to '/welcome' after auth callback and handle organization checks

This commit is contained in:
Usman Baig
2026-02-08 13:53:54 +01:00
parent 6d5c2d401a
commit c715bc4ce4
3 changed files with 523 additions and 7 deletions

View File

@@ -130,18 +130,15 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
useEffect(() => {
const checkOrg = async () => {
if (!loading && user) {
// * If we are on onboarding, skip check
if (pathname?.startsWith('/onboarding')) return
// * If we are processing auth callback, skip check to avoid redirect loops
if (pathname?.startsWith('/auth/callback')) return
try {
const organizations = await getUserOrganizations()
if (organizations.length === 0) {
// * No organizations -> Redirect to Onboarding
router.push('/onboarding')
if (pathname?.startsWith('/welcome')) return
router.push('/welcome')
return
}