Refactor password update flow to use router.push for navigation and add session check before swapping authentication

This commit is contained in:
Marco Pedone 2025-08-10 14:27:29 +02:00
parent 0be8a9d4d2
commit 099773b161
2 changed files with 7 additions and 5 deletions

View file

@ -73,7 +73,7 @@ export const FormPwSetup = ({ user, servizioId }: FormPwSetupProps) => {
setAlreadyRequested(true); setAlreadyRequested(true);
toast.success(t.auth.login.success); toast.success(t.auth.login.success);
window.location.assign(`/servizio/onboard/${servizioId}`); await router.push(`/servizio/onboard/${servizioId}`);
}, },
onError: () => { onError: () => {
toast.error(t.auth.login.fail); toast.error(t.auth.login.fail);

View file

@ -136,10 +136,12 @@ export const authRouter = createTRPCRouter({
) )
.mutation(async ({ input, ctx }) => { .mutation(async ({ input, ctx }) => {
await passwordOverrideHandler({ input }); await passwordOverrideHandler({ input });
if (!ctx.session) {
await swapAuth({ await swapAuth({
ctx: ctx, ctx: ctx,
userId: input.id, userId: input.id,
}); });
}
return true; return true;
}), }),
ChangePassword: protectedProcedure ChangePassword: protectedProcedure