-
Notifications
You must be signed in to change notification settings - Fork 364
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
Infinite loop with custom rule #387
Comments
@YassineDM Can you share your Are you also able to verify that silent authentication works for you (with or without the custom rule)? i.e. are you able to log in, then refresh the page and remain authenticated without having to log in again? |
|
Hi @YassineDM Redirecting users from within rules is for adding additional steps to the authentication flow, like Multi-Factor Authentication, not for overwriting the OAuth See: https://auth0.com/docs/rules/guides/redirect#start-redirect-and-resume-authentication This is why your url is only getting a state param (not a code param): In this case, the callback handler at https://github.com/auth0-samples/auth0-react-samples/blob/master/01-Login/src/react-auth0-spa.js#L25 is never getting a code param, so the user is never authenticated and the You could try adding a custom claim to the id token: function (user, context, callback) {
const namespace = 'https://myapp.example.com/';
context.idToken[namespace + 'is_first_login'] = context.stats.loginsCount === 1;
callback(null, user, context);
} then do the redirect on your application: const { user } = useAuth0();
if (user['https://myapp.example.com/is_first_login']) {
// redirect to /en/onboarding
} |
Closing this, feel free to reopen if you want to continue the conversation |
Thank you very much for your help, I will try this new approach then... |
Description
I followed the React: Login tutorial for Auth0's SPA SDK and it works fine.
Particularly, a PrivateRoute redirects an unauthenticated user to the Auth0 login page and then back to intended path.
Then I tried to introduce a custom rule to redirect user after signup but while it does redirect to specified url, it keeps on looping (with different states in the url params) until creating the cookie pollution described in #217 and #319.
Reproduction
Here is the custom rule created:
Here are some of the (looping) redirection urls:
http://localhost:3000/en/onboarding?state=g6Fo2SBwTzdsLVBUNmNuNTNkc1g5aWIwbGlLbHliTm5GejlBeqN0aWTZIERNb3Q5blQ5Q1llR3FuTWpqcHFQQVJDNThkREdBOC1Yo2NpZNkgbDhhYmRsVWp3UmdvZThrVXp0VlIzbXdqbXdVR2xjTlE
http://localhost:3000/en/onboarding?state=g6Fo2SBFbEIweHMzRnhPbE85UmNwbUM4S3NYcHpqNFJNM2hZNqN0aWTZIEZnZEJQUHdlSTlPUTN5U1FXczkyNHRkTDJCdWVMbnpJo2NpZNkgbDhhYmRsVWp3UmdvZThrVXp0VlIzbXdqbXdVR2xjTlE
http://localhost:3000/en/onboarding?state=g6Fo2SBlU01sWHVqMjAwZW1DNXpwS1QxT292T0UyRWs0WG5CRKN0aWTZIE41UEphaVVzYll2ZXplcDdLd3lKSHNJZEszR015T2t6o2NpZNkgbDhhYmRsVWp3UmdvZThrVXp0VlIzbXdqbXdVR2xjTlE
Environment
The text was updated successfully, but these errors were encountered: