From a907748f1e0b08ca195c5f9860620ab6c6b04115 Mon Sep 17 00:00:00 2001 From: flgubler-ergon <82028220+flgubler-ergon@users.noreply.github.com> Date: Tue, 28 Jan 2025 14:29:03 +0100 Subject: [PATCH 1/2] Make sure that AuthService.init() is always executed Similar topic as already discussed: If AuthService.init() is not executed before a login-flow is started, the login-flow never completes because no listener is registered with the @openid/appauth logic. In that case, debugging is very time-consuming because no helpful logging is provided. With this app-initializer logic of angular, we can be sure that the service is initialized before the UI-components are loaded. --- demos/angular-capacitor/src/app/app.module.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/demos/angular-capacitor/src/app/app.module.ts b/demos/angular-capacitor/src/app/app.module.ts index 3a3ccd9..f720b6d 100644 --- a/demos/angular-capacitor/src/app/app.module.ts +++ b/demos/angular-capacitor/src/app/app.module.ts @@ -19,7 +19,12 @@ import { CoreModule } from './core/core.module'; CoreModule ], providers: [ - { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } + { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, + { + provide: APP_INITIALIZER, + useFactory: (authService: AuthService) => authService.init(), + deps: [AuthService] + }, ], bootstrap: [AppComponent] }) From ddf80e65526e84353d6649b7f98454f61ccefaf7 Mon Sep 17 00:00:00 2001 From: Florian Gubler Date: Wed, 29 Jan 2025 08:20:57 +0100 Subject: [PATCH 2/2] Added necessary imports Sorry, changes outside of IDEs are dangerous --- demos/angular-capacitor/src/app/app.module.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/angular-capacitor/src/app/app.module.ts b/demos/angular-capacitor/src/app/app.module.ts index f720b6d..d8c8da2 100644 --- a/demos/angular-capacitor/src/app/app.module.ts +++ b/demos/angular-capacitor/src/app/app.module.ts @@ -1,13 +1,13 @@ -import { NgModule } from '@angular/core'; +import { NgModule, APP_INITIALIZER } from '@angular/core'; import { RouteReuseStrategy } from '@angular/router'; import { HttpClientModule } from '@angular/common/http'; import { BrowserModule } from '@angular/platform-browser'; - import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; import { CoreModule } from './core/core.module'; +import {AuthService} from "../../../../lib"; @NgModule({ declarations: [AppComponent],