Refactor password update flow to use router.push for navigation and add session check before swapping authentication
This commit is contained in:
parent
0be8a9d4d2
commit
099773b161
2 changed files with 7 additions and 5 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue