@@ -11,14 +11,19 @@ import { redirect } from '@sveltejs/kit';
1111import { resolve } from '$app/paths' ;
1212import { isEmailVerificationRequiredError } from '$lib/helpers/emailVerification' ;
1313
14- export const load : LayoutLoad = async ( { depends, parent } ) => {
14+ export const load : LayoutLoad = async ( { depends, parent, url } ) => {
1515 const { organizations, plansInfo } = await parent ( ) ;
1616
1717 depends ( Dependencies . RUNTIMES ) ;
1818 depends ( Dependencies . CONSOLE_VARIABLES ) ;
1919 depends ( Dependencies . ORGANIZATION ) ;
2020
2121 const { endpoint, project } = sdk . forConsole . client . config ;
22+ const verifyEmailUrl = resolve ( '/verify-email' ) ;
23+ const shouldRedirectToVerifyEmail = ( error : unknown ) =>
24+ error instanceof AppwriteException &&
25+ isEmailVerificationRequiredError ( error . type ) &&
26+ url . pathname !== verifyEmailUrl ;
2227
2328 const plansArrayPromise =
2429 plansInfo || ! isCloud
@@ -42,8 +47,8 @@ export const load: LayoutLoad = async ({ depends, parent }) => {
4247 } ) ,
4348 sdk . forConsole . console . variables ( )
4449 ] ) . catch ( ( error ) => {
45- if ( error instanceof AppwriteException && isEmailVerificationRequiredError ( error . type ) ) {
46- redirect ( 303 , resolve ( '/verify-email' ) ) ;
50+ if ( shouldRedirectToVerifyEmail ( error ) ) {
51+ redirect ( 303 , verifyEmailUrl ) ;
4752 }
4853
4954 throw error ;
@@ -74,8 +79,8 @@ export const load: LayoutLoad = async ({ depends, parent }) => {
7479 } )
7580 ) . total ;
7681 } catch ( e ) {
77- if ( e instanceof AppwriteException && isEmailVerificationRequiredError ( e . type ) ) {
78- redirect ( 303 , resolve ( '/verify-email' ) ) ;
82+ if ( shouldRedirectToVerifyEmail ( e ) ) {
83+ redirect ( 303 , verifyEmailUrl ) ;
7984 }
8085
8186 projectsCount = 0 ;
0 commit comments