mirror of
https://github.com/LukeHagar/website.git
synced 2025-12-09 12:57:48 +00:00
Fix redirects
This commit is contained in:
@@ -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');
|
||||
};
|
||||
|
||||
@@ -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, "/");
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ export const actions = {
|
||||
});
|
||||
|
||||
// Redirect to the account page.
|
||||
throw redirect(301, "/account");
|
||||
redirect(301, "/account");
|
||||
},
|
||||
};
|
||||
```
|
||||
@@ -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");
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
@@ -39,7 +39,7 @@ export const actions = {
|
||||
`${event.url.origin}/signup`
|
||||
);
|
||||
|
||||
throw redirect(301, redirectUrl);
|
||||
redirect(301, redirectUrl);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user