From 2d073dd72826f45be6ad1d7a79843daf74da9206 Mon Sep 17 00:00:00 2001
From: milanmajchrak <90026355+milanmajchrak@users.noreply.github.com>
Date: Thu, 21 Dec 2023 12:12:10 +0100
Subject: [PATCH] ufal/fe-not-show-shib-welcome-page
* Loaded property from the cfg and check if the page with idp attributes could be showed up. If not redirect the user to the home page. (#431)
---
.../autoregistration.component.html | 2 +-
.../autoregistration.component.ts | 26 ++++++++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/app/login-page/autoregistration/autoregistration.component.html b/src/app/login-page/autoregistration/autoregistration.component.html
index 8b9ac388f4e..8c2343ab387 100644
--- a/src/app/login-page/autoregistration/autoregistration.component.html
+++ b/src/app/login-page/autoregistration/autoregistration.component.html
@@ -1,4 +1,4 @@
-
+
{{'clarin.autoregistration.welcome.message' | translate}} {{dspaceName$ | async}}
diff --git a/src/app/login-page/autoregistration/autoregistration.component.ts b/src/app/login-page/autoregistration/autoregistration.component.ts
index 9ae0681ff18..bfd67f62e85 100644
--- a/src/app/login-page/autoregistration/autoregistration.component.ts
+++ b/src/app/login-page/autoregistration/autoregistration.component.ts
@@ -23,6 +23,7 @@ import { hasSucceeded } from 'src/app/core/data/request-entry-state.model';
import { FindListOptions } from '../../core/data/find-list-options.model';
import { getBaseUrl } from '../../shared/clarin-shared-util';
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
+import { RemoteData } from '../../core/data/remote-data';
/**
* This component is showed up when the user has clicked on the `verification token`.
@@ -62,6 +63,12 @@ export class AutoregistrationComponent implements OnInit {
*/
baseUrl = '';
+ /**
+ * Show attributes passed from the IdP or not.
+ * It could be disabled by the cfg property `authentication-shibboleth.show.idp-attributes`
+ */
+ showAttributes: BehaviorSubject
= new BehaviorSubject(false);
+
constructor(protected router: Router,
public route: ActivatedRoute,
private requestService: RequestService,
@@ -82,6 +89,14 @@ export class AutoregistrationComponent implements OnInit {
// Load the `ClarinVerificationToken` based on the `verificationToken` value
this.loadVerificationToken();
await this.assignBaseUrl();
+ await this.loadShowAttributes().then((value: RemoteData) => {
+ const stringBoolean = value?.payload?.values?.[0];
+ this.showAttributes.next(stringBoolean === 'true');
+ });
+
+ if (this.showAttributes.value === false) {
+ this.sendAutoLoginRequest();
+ }
}
/**
@@ -241,8 +256,17 @@ export class AutoregistrationComponent implements OnInit {
return baseUrlResponse?.values?.[0];
});
}
-}
+ /**
+ * Load the `authentication-shibboleth.show.idp-attributes` property from the cfg
+ */
+ async loadShowAttributes(): Promise {
+ return await this.configurationService.findByPropertyName('authentication-shibboleth.show.idp-attributes')
+ .pipe(
+ getFirstCompletedRemoteData()
+ ).toPromise();
+ }
+}
/**
* ShibHeaders string value from the verificationToken$ parsed to the objects.
*/