From b4769e10d2c2185a93861cee0ed9b1eb0049c7b5 Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Fri, 16 Aug 2024 20:53:25 +0800 Subject: [PATCH] fix(experience): avoid asking user to register when sign-up method is not supported --- .../use-sign-in-flow-code-verification.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/experience/src/containers/VerificationCode/use-sign-in-flow-code-verification.ts b/packages/experience/src/containers/VerificationCode/use-sign-in-flow-code-verification.ts index 68f9987cf0e..d6414f697fa 100644 --- a/packages/experience/src/containers/VerificationCode/use-sign-in-flow-code-verification.ts +++ b/packages/experience/src/containers/VerificationCode/use-sign-in-flow-code-verification.ts @@ -30,7 +30,7 @@ const useSignInFlowCodeVerification = ( const { show } = useConfirmModal(); const navigate = useNavigate(); const redirectTo = useGlobalRedirectTo(); - const { signInMode } = useSieMethods(); + const { signInMode, signUpMethods } = useSieMethods(); const handleError = useErrorHandler(); const registerWithIdentifierAsync = useApi(registerWithVerifiedIdentifier); @@ -44,8 +44,12 @@ const useSignInFlowCodeVerification = ( const showIdentifierErrorAlert = useIdentifierErrorAlert(); const identifierNotExistErrorHandler = useCallback(async () => { - // Should not redirect user to register if is sign-in only mode or bind social flow - if (signInMode === SignInMode.SignIn) { + /** + * Should not redirect user to register in the following cases: + * 1. in the sign-in only mode + * 2. the method is not supported for sign-up + */ + if (signInMode === SignInMode.SignIn || !signUpMethods.includes(method)) { void showIdentifierErrorAlert(IdentifierErrorType.IdentifierNotExist, method, target); return; @@ -81,16 +85,17 @@ const useSignInFlowCodeVerification = ( }); }, [ signInMode, + signUpMethods, + method, show, t, - method, target, - registerWithIdentifierAsync, showIdentifierErrorAlert, - navigate, + registerWithIdentifierAsync, handleError, preSignInErrorHandler, redirectTo, + navigate, ]); const errorHandlers = useMemo(