From 160b7fabca3bf7d8f4efd688021dc09e8834e177 Mon Sep 17 00:00:00 2001 From: Eunju Huss Date: Tue, 26 Nov 2024 14:58:42 +0100 Subject: [PATCH] reqeust logout when user is already signd up --- src/components/Signup/SignupApp.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Signup/SignupApp.tsx b/src/components/Signup/SignupApp.tsx index 7661f8567..61dfe8805 100644 --- a/src/components/Signup/SignupApp.tsx +++ b/src/components/Signup/SignupApp.tsx @@ -1,4 +1,5 @@ import { useActor } from "@xstate/react"; +import { fetchLogout } from "apis/eduidLogin"; import { fetchState } from "apis/eduidSignup"; import { RegisterEmail, SignupEmailForm } from "components/Signup/SignupEmailForm"; import { SignupGlobalStateContext } from "components/Signup/SignupGlobalState"; @@ -55,7 +56,11 @@ function SignupStart() { async function fetchSignupState(): Promise { const response = await dispatch(fetchState()); if (fetchState.fulfilled.match(response)) { - if (response.payload.state?.email.address) { + if (response.payload.state.already_signed_up) { + dispatch(fetchLogout({})); + } + const { email } = response.payload.state || {}; + if (email?.address) { signupContext.signupService.send({ type: "BYPASS" }); } else signupContext.signupService.send({ type: "COMPLETE" }); }