Skip to content

Commit 0e963cd

Browse files
committed
remove llop
1 parent d204d6b commit 0e963cd

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

src/routes/(console)/+layout.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ import { redirect } from '@sveltejs/kit';
1111
import { resolve } from '$app/paths';
1212
import { 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;

src/routes/(console)/verify-email/+page.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@ import type { PageLoad } from './$types';
44
import { Dependencies } from '$lib/constants';
55
import { sdk } from '$lib/stores/sdk';
66
import { addNotification } from '$lib/stores/notifications';
7-
import { isEmailVerificationEnabled } from '$lib/helpers/emailVerification';
87

98
export const load: PageLoad = async ({ parent, depends, url }) => {
10-
const { account, consoleVariables } = await parent();
11-
12-
const emailVerificationEnabled = isEmailVerificationEnabled(consoleVariables);
13-
14-
if (!emailVerificationEnabled) {
15-
redirect(303, resolve('/'));
16-
}
9+
const { account } = await parent();
1710

1811
depends(Dependencies.ACCOUNT);
1912

0 commit comments

Comments
 (0)