@@ -7,9 +7,17 @@ import { makePlansMap } from '$lib/helpers/billing';
77import { plansInfo as plansInfoStore } from '$lib/stores/billing' ;
88import { normalizeConsoleVariables } from '$lib/helpers/domains' ;
99import { syncServerTime } from '$lib/helpers/fingerprint' ;
10+ import { redirect } from '@sveltejs/kit' ;
11+ import { resolve } from '$app/paths' ;
1012
11- export const load : LayoutLoad = async ( { depends, parent } ) => {
12- const { organizations, plansInfo } = await parent ( ) ;
13+ function isEmailVerificationEnabledFromBackend ( flag : string | undefined ) : boolean {
14+ if ( ! flag ) return false ;
15+ const normalized = flag . toLowerCase ( ) ;
16+ return normalized === 'enabled' || normalized === 'true' || normalized === '1' ;
17+ }
18+
19+ export const load : LayoutLoad = async ( { depends, parent, url } ) => {
20+ const { organizations, plansInfo, account } = await parent ( ) ;
1321
1422 depends ( Dependencies . RUNTIMES ) ;
1523 depends ( Dependencies . CONSOLE_VARIABLES ) ;
@@ -42,6 +50,18 @@ export const load: LayoutLoad = async ({ depends, parent }) => {
4250
4351 const consoleVariables = normalizeConsoleVariables ( rawConsoleVariables ) ;
4452
53+ const emailVerificationEnabled = isEmailVerificationEnabledFromBackend (
54+ consoleVariables . _APP_CONSOLE_EMAIL_VERIFICATION
55+ ) ;
56+
57+ if ( isCloud && account && ! account . emailVerification && emailVerificationEnabled ) {
58+ const isVerifyEmailPage = url . pathname === resolve ( '/verify-email' ) ;
59+
60+ if ( ! isVerifyEmailPage ) {
61+ redirect ( 303 , resolve ( '/verify-email' ) ) ;
62+ }
63+ }
64+
4565 let fallbackPlansInfoArray = plansInfo ;
4666 if ( ! fallbackPlansInfoArray ) {
4767 fallbackPlansInfoArray = makePlansMap ( plansArray ) ;
0 commit comments