Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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>(
Expand Down
Loading