I have been trying to redirect a user to a different route based on a condition. Below is the config for auth.
authConfig: {
redirectUri: window.location.origin + '/portal',
responseType: 'token id_token',
strictDiscoveryDocumentValidation: false,
tokenEndpoint: 'https://idmcc.b2clogin.com/idmcc.onmicrosoft.com/b2c_1_cc/oauth2/v2.0/token',
loginUrl: 'https://idmcc.b2clogin.com/idmcc.onmicrosoft.com/b2c_1_cc/oauth2/v2.0/token',
scope: 'openid profile https://idmcc.onmicrosoft.com/ccapi/user_impersonation',
skipIssuerCheck: true,
clearHashAfterLogin: true,
oidc: true,
}
After a successful login, user is redirected to localhost:4200/portal but now I want user to go to a different page depending on the returning url. E.g User tried to access a page which is protected and after login I want to go to that page. So I want to dynamically modify redirectUri.
Not sure I understand the full question, but if you want to do something like this:
"User tried to access a page which is protected and after login I want to go to that page"
Look into guards: https://angular.io/api/router/CanActivate where if someone doesn't have permissions you can redirect