I’ve just implemented the login and register functionalities for an SPA Rect app using auth0.
I’d like to render the auth0 login page straight away when a user is not logged or registered.
Right now I just have a button on a “landing page” which the user can click to then be redirected to the auth0 login page. And, if a user is logged it then renders the react router dom content.
How can I ensure that I don’t show the landing page but rather be automatically on the auth0 log in page if someone isn’t logged in or registered?
Can you let us know what resources have you been following in your implementation? Based on that we should be able to advise something here. Thank you!
So it’s actually a bit tricky. You would potentially need to put some logic on your top-level component, likely App to always trigger the login action if the user is not authenticated
Yeah I was thinking something similar before. Basically, what I did was to put the loginWithRedirect() into a useEffect so that when the page was initially rendered it automatically redirected the user.
But the issue with this was then when I then clicked on login it redirected me to the routing page which was correct but then it somehow caused and infinite loop and logged me out again.
Here’s what I got going on right now. I guess I’ll just create a landing page where I’ll put the login button. Shouldn’t be a big deal.
Thanks, Konrad! Actually, it’s fine now. I just decided to quickly create a landing page for it. Meaning, there’s no need anymore to have the login page as the first page. Thanks for your help tho!