hello this code is taken from here : supertokens-a...
# general
t
hello this code is taken from here : supertokens-auth-react/examples/with-sign-in-up-split-emailpassword/
Copy code
EmailPasswordSignUp_Override: ({ DefaultComponent, ...props }) => {
                        /* if the user visits the /signup route, we want to show the
                         default implementation. If thy visit the /signin?show=signup
                         route, we want to show the sign in UI, so we redirect them to /signin
                         which shows the sign in UI.
                        */
                        const [showUI, setShowUI] = useState(false);
                        useEffect(() => {
                            if (window.location.pathname === "/signup") {
                                setShowUI(true);
                            } else if (window.location.pathname === "/signin") {
                                window.location.href = "/signin";
                            } else {
                                setShowUI(true);
                            }
                        }, []);
                        if (showUI) {
                            return <DefaultComponent {...props} />;
                        } else {
                            return null;
                        }
                    },
is this part of the comment correct? "If thy visit the /signin?show=signup route, we want to show the sign in UI, so we redirect them to /signin which shows the sign in UI." I'm confused
r
hey @User so by default, we show the sign in and sign up UI on the same route. And you can switch between the two using the query param called
show
. In the split UI, we are still rendering the same component, but just hiding the sign up UI in the /signin route. So technically, someone can still use the
show
query param to navigate to the hidden sign up UI. So in case that happens, we redirect to the right path.
t
okay, got it!
thank you
5 Views