@open-rlb/ng-app 3.0.8 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -446,6 +446,11 @@ class AppsService {
446
446
  this.store.dispatch(AppContextActions.setCurrentApp({ app, mode: viewMode, url }));
447
447
  }
448
448
  initAuthProviders(store, confAuth) {
449
+ const currentProviderInStore = this.store.selectSignal((state) => state[authsFeatureKey].currentProvider)();
450
+ if (currentProviderInStore) {
451
+ this.logger.info(`Auth provider already set to '${currentProviderInStore}' by Initializer. AppsService initAuthProviders skipping init.`);
452
+ return;
453
+ }
449
454
  if (!confAuth?.providers?.length) {
450
455
  this.logger.warn('No auth providers configured.');
451
456
  return;
@@ -1310,13 +1315,38 @@ class AuthenticationService {
1310
1315
  return this.oidc.checkAuthMultiple(url)
1311
1316
  .pipe(tap(data => {
1312
1317
  this.logger.warn(`oidc checkAuthMultiple check, response: ${JSON.stringify(data)}; looking for at least one isAuthenticated`);
1313
- if (data.some(o => o.isAuthenticated)) {
1318
+ const authenticatedConfig = data.find(o => o.isAuthenticated);
1319
+ if (authenticatedConfig && authenticatedConfig.configId) {
1320
+ this.logger.info(`User is authenticated with provider: ${authenticatedConfig.configId}. Updating Store.`);
1321
+ // first dispatch to prevent recalculate in apps service
1322
+ this.store.dispatch(AuthActions.setCurrentProvider({
1323
+ currentProvider: authenticatedConfig.configId
1324
+ }));
1325
+ // Redirect logic -> clean query params
1314
1326
  const redirect = this.cookiesService.getCookie('loginRedirectUrl');
1327
+ this.logger.info(`Correct provider dispatched, redirectUrl: ${redirect}`);
1315
1328
  if (redirect) {
1316
1329
  this.cookiesService.deleteCookie('loginRedirectUrl');
1317
- this.router.navigate([redirect]);
1330
+ this.router.navigate([redirect], { queryParams: {} });
1318
1331
  }
1332
+ else {
1333
+ this.router.navigate([], {
1334
+ queryParams: {},
1335
+ replaceUrl: true,
1336
+ relativeTo: this.router.routerState.root
1337
+ });
1338
+ }
1339
+ }
1340
+ else {
1341
+ this.logger.warn(`No authenticatedConfig found for ${url}`);
1319
1342
  }
1343
+ // if (data.some(o => o.isAuthenticated)) {
1344
+ // const redirect = this.cookiesService.getCookie('loginRedirectUrl');
1345
+ // if (redirect) {
1346
+ // this.cookiesService.deleteCookie('loginRedirectUrl');
1347
+ // this.router.navigate([redirect]);
1348
+ // }
1349
+ // }
1320
1350
  }));
1321
1351
  //}
1322
1352
  }