Skip to content

Commit

Permalink
check cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
rezk2ll committed Dec 21, 2023
1 parent ab55cc5 commit a307383
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/routes/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ import { validateName, validateNickName } from '$lib/utils/username';
import authService from '$lib/services/auth';
import { extractMainDomain } from '$lib/utils/url';

export const load: PageServerLoad = async ({ locals, url }) => {
export const load: PageServerLoad = async ({ locals, url, cookies }) => {
await Client.getClient();

const { session } = locals;
const redirectUrl = url.searchParams.get('post_registered_redirect_url') ?? null;

const cookie = cookies.get(authService.cookieName);

if (redirectUrl) {
await session.update((data) => ({
...data,
redirectUrl
}));
}

if (session.data.authenticated === true) {
if (session.data.authenticated === true && cookie) {
throw redirect(302, '/success');
}
};
Expand Down Expand Up @@ -220,8 +222,6 @@ export const actions: Actions = {
throw err;
}

console.error({ err });

return fail(500, { failed_login: true });
}
}
Expand Down

0 comments on commit a307383

Please sign in to comment.