Hi, I want the user back to the route that they redirected from to auth0 authentication page, when logged in/signed up. I dont understand how to achieve it since, callback urls are not helping here. Any help would be appreciated. Thanks
Hi xeibra,
Thanks for reaching out to Auth0 Community!
Please check this previous similar question came in community How to configure Auth0 application to redirect to a specific URL after login?. hope this helps!
Regards,
Pavan
Hi @pavan.bn, thanks for replying. I did do that and it even took me to the desired route but my user is not authenticated, the isAutheticated prop is still false for some reason. Is there any other step that I need to do after adding a action to my login flow? I am using reactjs btw
Hi xeibra,
Thanks for giving more inputs, i tried from my end there are couple of things i can suggest,
- Make sure your using @auth0/auth0-react package.
- Check once you have configured the URL’s
- Please try using the below code once
import { useAuth0 } from "@auth0/auth0-react";
import "./App.css";
const LoginButton = () => {
const { isAuthenticated, loginWithRedirect } = useAuth0();
useEffect(() => {
const checkAuthentication = async () => {
if (isAuthenticated) {
console.log("After Login - isAuthenticated:", isAuthenticated);
}
};
checkAuthentication();
}, [isAuthenticated]);
const handleLogin = () => {
// Log isAuthenticated before login
console.log("Before Login - isAuthenticated:", isAuthenticated);
loginWithRedirect();
};
return (
<div className="container">
{!isAuthenticated && (
<button
onClick={handleLogin}
className="login-button"
>
Log In
</button>
)}
</div>
);
};
export default LoginButton;
for the above code post login, isAuthenticated showing as true in console.
Regards,
Pavan.
1 Like