diff --git a/global.d.ts b/global.d.ts index 059e47732..eae4c0863 100644 --- a/global.d.ts +++ b/global.d.ts @@ -8,6 +8,7 @@ declare const __USE_PROD_CONFIG__: boolean interface Window { __CONFIG__: { mixpanel_token?: string + require_whitelist?: boolean subscription_required?: boolean server_health_alert?: { message: string diff --git a/src/platform/onboarding/cloud/UserCheckView.vue b/src/platform/onboarding/cloud/UserCheckView.vue index ed14d2d27..586519587 100644 --- a/src/platform/onboarding/cloud/UserCheckView.vue +++ b/src/platform/onboarding/cloud/UserCheckView.vue @@ -61,19 +61,25 @@ const { return } + // Survey is required for all users if (!surveyStatus) { skeletonType.value = 'survey' await router.replace({ name: 'cloud-survey' }) return } - if (cloudUserStats.status !== 'active') { + // Check if we should enforce whitelist requirement + const requireWhitelist = window.__CONFIG__?.require_whitelist ?? true + + // Check feature flag and redirect non-active users if whitelist is required + if (requireWhitelist && cloudUserStats.status !== 'active') { + // Feature flag ON: Show waitlist page for non-active users skeletonType.value = 'waitlist' await router.replace({ name: 'cloud-waitlist' }) return } - // User is fully onboarded + // User is fully onboarded (active or whitelist check disabled) await router.replace('/') }), null, diff --git a/src/router.ts b/src/router.ts index 2c28d1fda..5fd39cb3c 100644 --- a/src/router.ts +++ b/src/router.ts @@ -192,15 +192,19 @@ router.beforeEach(async (to, _from, next) => { const userStatus = await getUserCloudStatus() const surveyCompleted = await getSurveyCompletedStatus() - // If user is not active (waitlisted), redirect based on survey status - if (userStatus.status !== 'active') { - if (!surveyCompleted) { - return next({ name: 'cloud-survey' }) - } else { - return next({ name: 'cloud-waitlist' }) - } + // Survey is required for all users regardless of whitelist status + if (!surveyCompleted) { + return next({ name: 'cloud-survey' }) } - // User is active, allow access to root + + // Check if we should enforce whitelist requirement + const requireWhitelist = window.__CONFIG__?.require_whitelist ?? true + + // Check feature flag and redirect non-active users if whitelist is required + if (requireWhitelist && userStatus.status !== 'active') { + return next({ name: 'cloud-waitlist' }) + } + // User is active or whitelist check disabled: Allow access to root } catch (error) { console.error('Failed to check user status:', error) // On error, redirect to user-check as fallback