Fix redirects

This commit is contained in:
Vincent (Wen Yu) Ge
2024-03-11 16:05:46 +00:00
parent 30f28cee78
commit 7055efcd1b
7 changed files with 9 additions and 9 deletions

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
export const load: PageLoad = async () => {
throw redirect(303, '/docs/tutorials/sveltekit-csr-auth/step-1');
redirect(303, '/docs/tutorials/sveltekit-csr-auth/step-1');
};

View File

@@ -15,7 +15,7 @@ export const load = async ({ parent }) => {
// Gets the data returned from the root layout
const { account } = await parent();
if (account) {
throw redirect(303, "/");
redirect(303, "/");
}
};
```

View File

@@ -62,11 +62,11 @@ export async function load({ locals }) {
// Access our user from locals.
if (!locals.user) {
// If no user is logged in, redirect to the sign up page.
throw redirect(301, '/signup');
redirect(301, '/signup');
}
// If the user is logged in, redirect to the account page.
throw redirect(301, '/account');
redirect(301, '/account');
}
```

View File

@@ -51,7 +51,7 @@ export const actions = {
});
// Redirect to the account page.
throw redirect(301, "/account");
redirect(301, "/account");
},
};
```

View File

@@ -15,7 +15,7 @@ import { redirect } from "@sveltejs/kit";
export async function load({ locals }) {
// Logged out users can't access this page.
if (!locals.user) throw redirect(301, "/signup");
if (!locals.user) redirect(301, "/signup");
// Pass the stored user local to the page.
return {
@@ -34,7 +34,7 @@ export const actions = {
event.cookies.delete(SESSION_COOKIE, { path: "/" });
// Redirect to the sign up page.
throw redirect(301, "/signup");
redirect(301, "/signup");
},
};
```

View File

@@ -39,7 +39,7 @@ export const actions = {
`${event.url.origin}/signup`
);
throw redirect(301, redirectUrl);
redirect(301, redirectUrl);
},
};