Version
21.0.1
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
ERROR Error: Please provide a configuration before setting up the module
at _LoginService.login (angular-auth-oidc-client.mjs:5748:13)
at angular-auth-oidc-client.mjs:6624:22
at map.js:7:37
at OperatorSubscriber2._this._next (OperatorSubscriber.js:15:21)
at Subscriber2.next (Subscriber.js:34:18)
at Observable2._subscribe (innerFrom.js:51:24)
at Observable2._trySubscribe (Observable.js:38:25)
at Observable.js:32:31
at errorContext (errorContext.js:19:9)
at Observable2.subscribe (Observable.js:23:9)
Steps to reproduce the behavior
With an Angular 21.2 application, setting the guard function `autoLoginPartialRoutesGuard` as a CanMatchFn, like this:
"canMatch: [autoLoginPartialRoutesGuard],"
raises the above Error at runtime.
A clear and concise description of what you expected to happen.
We expect the guard to launch the `checkAuth`, and if not authenticated redirect to the IDP provider.
Additional context
Angular has changed the CanMatchFn in Angular 21.2 (adding of a new 3rd parameter).
Here is the type in Angular 20:
https://v20.angular.dev/api/router/CanMatchFn
type CanMatchFn = (route: Route, segments: UrlSegment[]) => MaybeAsync<GuardResult>;
And here is the new one in Angular 21.2:
https://angular.dev/api/router/CanMatchFn
type CanMatchFn = (route: Route, segments: UrlSegment[], currentSnapshot?: PartialMatchRouteSnapshot) => MaybeAsync<GuardResult>;
The lib has signed the guard function with 3 parameters, the last one being just for internal purpose:
https://github.com/damienbod/angular-auth-oidc-client/blob/main/projects/angular-auth-oidc-client/src/lib/auto-login/auto-login-partial-routes.guard.ts#L76
Now Angular calls this function with a new 3rd parameter (currentSnapshot), the lib makes a confusion and thinks it is the configId. Of course it is not, and then we get a configuration to null into the checkAuth function:
https://github.com/damienbod/angular-auth-oidc-client/blob/main/projects/angular-auth-oidc-client/src/lib/auto-login/auto-login-partial-routes.guard.ts#L122
Finally, this null value configuration is passed to the LoginService in the method login, that raises the Error 'Please provide a configuration before setting up the module'.
https://github.com/damienbod/angular-auth-oidc-client/blob/main/projects/angular-auth-oidc-client/src/lib/login/login.service.ts#L23
NOTE: the problem is not present when using canActivate (because it still has only 2 parameters)
Version
21.0.1
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Steps to reproduce the behavior
A clear and concise description of what you expected to happen.
Additional context
Angular has changed the
CanMatchFnin Angular 21.2 (adding of a new 3rd parameter).Here is the type in Angular 20:
https://v20.angular.dev/api/router/CanMatchFn
And here is the new one in Angular 21.2:
https://angular.dev/api/router/CanMatchFn
The lib has signed the guard function with 3 parameters, the last one being just for internal purpose:
https://github.com/damienbod/angular-auth-oidc-client/blob/main/projects/angular-auth-oidc-client/src/lib/auto-login/auto-login-partial-routes.guard.ts#L76
Now Angular calls this function with a new 3rd parameter (
currentSnapshot), the lib makes a confusion and thinks it is theconfigId. Of course it is not, and then we get aconfigurationtonullinto thecheckAuthfunction:https://github.com/damienbod/angular-auth-oidc-client/blob/main/projects/angular-auth-oidc-client/src/lib/auto-login/auto-login-partial-routes.guard.ts#L122
Finally, this null value configuration is passed to the
LoginServicein the methodlogin, that raises the Error 'Please provide a configuration before setting up the module'.https://github.com/damienbod/angular-auth-oidc-client/blob/main/projects/angular-auth-oidc-client/src/lib/login/login.service.ts#L23
NOTE: the problem is not present when using
canActivate(because it still has only 2 parameters)