0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(experience): avoid asking user to register when sign-up method is not supported

This commit is contained in:
Xiao Yijun 2024-08-16 20:53:25 +08:00
parent e9eb212f48
commit b4769e10d2
No known key found for this signature in database
GPG key ID: 6F648FC1262DB420

View file

@ -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<ErrorHandlers>(