🐛 Fix login redirections
Tim Izzo tim@octree.ch
Thu, 29 Aug 2024 17:46:47 +0200
3 files changed,
23 insertions(+),
10 deletions(-)
M
.dockerignore
→
.dockerignore
@@ -9,4 +9,5 @@ backend/build
frontend/.next .gitlab-ci.yml banner.jpg -*.md+*.md +e2e
M
backend/src/graphql/passenger/createPassenger.ts
→
backend/src/graphql/passenger/createPassenger.ts
@@ -56,15 +56,19 @@ .locale(createdPassenger.user.lang || "en")
.format("dddd LL") : ""; const datetime = `${date} ${travel.departureTime || ""}`; - strapi.entityService.create("api::notification.notification", { - data: { - type: "ContactTripCreator", - event: createdPassenger.event.id, - user: createdPassenger.user.id, - // @ts-expect-error - payload: { travel, driver, datetime }, - }, - }); + try { + await strapi.entityService.create("api::notification.notification", { + data: { + type: "ContactTripCreator", + event: createdPassenger.event.id, + user: createdPassenger.user.id, + // @ts-expect-error + payload: { travel, driver, datetime }, + }, + }); + } catch (error) { + console.error(error); + } } const { toEntityResponse } = strapi
M
frontend/pages/auth/login.tsx
→
frontend/pages/auth/login.tsx
@@ -9,6 +9,7 @@ import SignInForm from '../../containers/SignInForm';
import LanguagesIcon from '../../containers/Languages/Icon'; import pageUtils from '../../lib/pageUtils'; import Container from '@mui/material/Container'; +import Cookies from 'cookies'; interface PageProps { error?: string;@@ -53,6 +54,13 @@ else
return pageUtils.getServerSideProps(async ctx => { const error = ctx.query?.error || null; const emailConfirmation = ctx.query?.confirmed === 'true'; + const redirectPath = ctx.query?.redirectPath; + + if (redirectPath) { + const cookies = new Cookies(ctx.req, ctx.res); + cookies.set('redirectPath', redirectPath); + } + return {props: {error, emailConfirmation}}; })(context); };