Skip to content

[Question]: Automatic redirect to original url after authentication #2070

Open
@MatthiasHuygelen

Description

@MatthiasHuygelen

What Version of the library are you using?
19.0.0
...

info
I am implementing authentication using Azure B2C. After successfully logging in the application redirects back to the original location instead of /draw as intended.

The configuration values stored in the browser's storage seem correct, and the authentication tokens are available. However:

  • isAuthenticated is false (as observed from the oidcSecurityService.checkAuth() log).
  • The isAuthenticated$ observable reports true.

When I try accessing /draw again, the same behavior occurs.

After enabling withDebugTracing I also see the following error

Router Event: NavigationCancel
router.mjs:7168 NavigationCancel(id: 1, url: '/draw?state=014ce5c0396f759a28378b99548a242f2f....&code={CODE}')
router.mjs:7169 NavigationCancel {id: 1, url: '/draw?state=014ce5c0396f759a28378b99548a242f2f....', reason: '', code: 3, type: 2}
chunk-RTJCVXYN.js?v=88d6ca69:sourcemap:5936 ERROR Error: could not find matching config for state 014ce5c0396f759a28378b99548a242f2f....

Implementation

export const authConfig: PassedInitialConfig = {
  config: {
    authority:
      'https://{APPLICATION}.b2clogin.com/{APPLICATION}.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_SIGN_IN_SIGN_UP',
    authWellknownEndpointUrl:
      'https://{APPLICATION}.b2clogin.com/{APPLICATION}.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=B2C_1_SIGN_IN_SIGN_UP',
    redirectUrl: `${window.location.origin}/draw`,
    postLogoutRedirectUri: window.location.origin,
    unauthorizedRoute: '/unauthorized',
    clientId: '{CLIENT_ID}',
    scope: 'openid profile offline_access', 
    responseType: 'code',
    silentRenew: true,
    useRefreshToken: true,
    autoUserInfo: false,
    issValidationOff: false,
    logLevel: LogLevel.Debug,
    checkRedirectUrlWhenCheckingIfIsCallback: false,
    customParamsAuthRequest: {
      prompt: 'login', 
    },
  },
};
{
    path: 'draw',
    canActivateChild: [autoLoginPartialRoutesGuard],
    children: [
            ...
    ],
  },

Question
Am I missing any settings or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions