Search code examples
angularauth0

Angular 2+ Prevent user to navigate back to Auth0 callback


My Angular app uses auth0, and after the login is successful, auth0 will redirect the user to my website's /callback.

It's working completely fine, but I want to prevent the user to reach this /callback state by hitting the "previous page" button for example.

Because navigating to /callback after being succesfully authenticated will display an error.

What is the best way to achieve this ?


Solution

  • Use _router.navigate([your, redirect, route], { replaceUrl: true }); to replace current state. https://angular.io/api/router/NavigationExtras#replaceUrl