Wondering how to go to the login page without pressing a button. In the examples, the button is always provided and you have to trigger loginWithRedirect() by clicking a button.
This issue is still valid.
The code below leads to an infinite loop.
if (!isAuthenticated) {
loginWithRedirect();
}
My code:
import React from 'react'
import { App } from './views/App'
import { useAuth0 } from '@auth0/auth0-react'
export const App = () => {
const { loginWithRedirect, isAuthenticated } = useAuth0()
if (!isAuthenticated) {
loginWithRedirect()
}
return <App />
}
I’d like to redirect users to the login page if they hit my /login callbackUrl directly, but it also leads to an infinite loop.
I’ve tried using conditions with the isAuthenticated, user and isLoading props, but isLoading is not set to false when a user is not authenticated.
Using only isAuthenticated and user leads to an infinite loop and ignores my code to handle actual the actual login process because isLoading and isAuthenticated are true and false, respectively, for a few seconds.