diff --git a/frontend/src/routes/profile/+page.server.js b/frontend/src/routes/profile/+page.server.js index 8a25747..5d7a251 100644 --- a/frontend/src/routes/profile/+page.server.js +++ b/frontend/src/routes/profile/+page.server.js @@ -9,7 +9,7 @@ export async function load({ cookies }) { if (!data.ok) { if (data.status === 401) { - return redirect(302, "/login?r=401") // redirect after login + return redirect(302, "/login?r=401&to=/profile") } return error(500, "Error fetching profile, please try again later.") diff --git a/frontend/src/routes/review/[toilet]/+page.server.js b/frontend/src/routes/review/[toilet]/+page.server.js index db3f9b2..9dbdc68 100644 --- a/frontend/src/routes/review/[toilet]/+page.server.js +++ b/frontend/src/routes/review/[toilet]/+page.server.js @@ -10,7 +10,7 @@ export async function load({ params, cookies }) { if (!data.ok) { if (data.status === 401) { - return redirect(302, "/login?r=401") // TODO: redirect + return redirect(302, `/login?r=401&to=/review/${params.toilet}`) } return error(500, "Error fetching user, please try again later.") @@ -50,7 +50,7 @@ export const actions = { if (!response.ok) { if (data.status === 401) { - return redirect(302, "/login?r=401") // TODO: redirect + return redirect(302, `/login?r=401&to=/review/${toilet}`) } if (response.status === 400) { return fail(400, { error: "Error creating review" }) diff --git a/frontend/src/routes/toilets/new/+page.server.js b/frontend/src/routes/toilets/new/+page.server.js index b967874..a2c073c 100644 --- a/frontend/src/routes/toilets/new/+page.server.js +++ b/frontend/src/routes/toilets/new/+page.server.js @@ -10,7 +10,7 @@ export async function load({ cookies }) { if (!data.ok) { if (data.status === 401) { - return redirect(302, "/login?r=401") // TODO: redirect + return redirect(302, "/login?r=401&to=/toilets/new") } return error(500, "Error fetching user, please try again later.") @@ -46,7 +46,7 @@ export const actions = { if (!response.ok) { if (data.status === 401) { - return redirect(302, "/login?r=401") // TODO: redirect + return redirect(302, "/login?r=401&to=/toilets/new") } if (response.status === 400) { return fail(400, { error: "Error creating toilet" })