Skip to content

Commit

Permalink
add redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-intuitem committed Apr 1, 2024
1 parent 05dc6f9 commit 58eb8f1
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ export const actions: Actions = {
}

setFlash({ type: 'success', message: m.passwordSuccessfullyChanged() }, event);
redirect(302, '/my-profile');
redirect(302, 'my-profile');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export const actions: Actions = {
}

setFlash({ type: 'success', message: m.passwordSuccessfullySet() }, event);
redirect(302, '/users');
redirect(302, 'users');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const actions: Actions = {
}
if (response.error) {
setFlash({ type: 'error', message: response.error }, event);
redirect(302, '/login');
redirect(302, 'login');
}
return fail(400, { form });
}
Expand All @@ -52,6 +52,6 @@ export const actions: Actions = {
},
event
);
redirect(302, '/login');
redirect(302, 'login');
}
};
2 changes: 1 addition & 1 deletion frontend/src/routes/(authentication)/login/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { setError, superValidate } from 'sveltekit-superforms/server';
export const load: PageServerLoad = async ({ request, locals }) => {
// redirect user if already logged in
if (locals.user) {
redirect(302, '/analytics');
redirect(302, 'analytics');
}

const form = await superValidate(request, loginSchema);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/(authentication)/logout/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const GET = async ({ locals }) => {
if (!locals.user) {
redirect(302, `/login?next=/home`);
}
redirect(302, '/analytics');
redirect(302, 'analytics');
};

export const POST = async ({ fetch, cookies }) => {
Expand All @@ -24,5 +24,5 @@ export const POST = async ({ fetch, cookies }) => {

cookies.delete('sessionid', { path: '/' });

redirect(302, '/login');
redirect(302, 'login');
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as m from '$paraglide/messages';
export const load: PageServerLoad = async (event) => {
// redirect user if already logged in
if (event.locals.user) {
redirect(302, '/');
redirect(302, '');
}

const form = await superValidate(event.request, emailSchema);
Expand Down Expand Up @@ -55,7 +55,7 @@ export const actions: Actions = {
},
event
);
redirect(302, '/login');
redirect(302, 'login');
}

const endpoint = `${BASE_API_URL}/iam/password-reset/`;
Expand All @@ -76,7 +76,7 @@ export const actions: Actions = {
if (response.error) {
setFlash({ type: 'error', message: response.error }, event);
}
redirect(302, '/login');
redirect(302, 'login');
}

setFlash(
Expand All @@ -87,6 +87,6 @@ export const actions: Actions = {
event
);

redirect(302, '/login');
redirect(302, 'login');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export const actions: Actions = {
}
if (response.error) {
setFlash({ type: 'error', message: response.error }, event);
redirect(302, '/login');
redirect(302, 'login');
}
return fail(400, { form });
}

setFlash({ type: 'success', message: m.passwordSuccessfullyReset() }, event);
redirect(302, '/login');
redirect(302, 'login');
}
};

0 comments on commit 58eb8f1

Please sign in to comment.