From 099773b1617b34b3f4c9143999349b2a07baf894 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Sun, 10 Aug 2025 14:27:29 +0200 Subject: [PATCH] Refactor password update flow to use router.push for navigation and add session check before swapping authentication --- apps/infoalloggi/src/forms/FormPwSetup.tsx | 2 +- apps/infoalloggi/src/server/api/routers/auth.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/infoalloggi/src/forms/FormPwSetup.tsx b/apps/infoalloggi/src/forms/FormPwSetup.tsx index 7c37498..fdd5721 100644 --- a/apps/infoalloggi/src/forms/FormPwSetup.tsx +++ b/apps/infoalloggi/src/forms/FormPwSetup.tsx @@ -73,7 +73,7 @@ export const FormPwSetup = ({ user, servizioId }: FormPwSetupProps) => { setAlreadyRequested(true); toast.success(t.auth.login.success); - window.location.assign(`/servizio/onboard/${servizioId}`); + await router.push(`/servizio/onboard/${servizioId}`); }, onError: () => { toast.error(t.auth.login.fail); diff --git a/apps/infoalloggi/src/server/api/routers/auth.ts b/apps/infoalloggi/src/server/api/routers/auth.ts index 5c88803..41fb42f 100644 --- a/apps/infoalloggi/src/server/api/routers/auth.ts +++ b/apps/infoalloggi/src/server/api/routers/auth.ts @@ -136,10 +136,12 @@ export const authRouter = createTRPCRouter({ ) .mutation(async ({ input, ctx }) => { await passwordOverrideHandler({ input }); - await swapAuth({ - ctx: ctx, - userId: input.id, - }); + if (!ctx.session) { + await swapAuth({ + ctx: ctx, + userId: input.id, + }); + } return true; }), ChangePassword: protectedProcedure