Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 29, 2025

Login was broken because checkAuth() was only called in AppComponent.ngOnInit(), which occurs after routing initialization. Angular 21 requires OIDC authentication to be resolved before the app bootstraps.

Changes

  • app.module.ts: Add APP_INITIALIZER provider that invokes checkAuth() during bootstrap

    export function configureAuth(oidcSecurityService: OidcSecurityService) {
      return () => firstValueFrom(oidcSecurityService.checkAuth());
    }
    
    providers: [{
      provide: APP_INITIALIZER,
      useFactory: configureAuth,
      deps: [OidcSecurityService],
      multi: true,
    }]
  • app.component.ts: Subscribe to isAuthenticated$ observable instead of calling checkAuth() to avoid redundant auth checks

  • dataeventrecords components: Fix AuthenticatedResult type handling - extract boolean from result object when passing to getData()

Original prompt

Login in Angular does not work in the https://github.com/damienbod/AspNetCoreOpeniddict/tree/feature/angular21 branch, please fix in this branch


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@damienbod damienbod marked this pull request as ready for review November 29, 2025 20:01
Copilot AI changed the title [WIP] Fix login functionality in Angular Fix Angular 21 login by adding APP_INITIALIZER for OIDC authentication Nov 29, 2025
Copilot AI requested a review from damienbod November 29, 2025 20:06
@damienbod damienbod merged commit bf85892 into main Nov 29, 2025
2 checks passed
@damienbod damienbod deleted the copilot/fix-angular-login-issue branch November 29, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants