Skip to content

Commit

Permalink
Loaded property from the cfg and check if the page with idp attribute…
Browse files Browse the repository at this point in the history
…s could be showed up. If not redirect the user to the home page.
  • Loading branch information
milanmajchrak committed Dec 20, 2023
1 parent bb8ed5f commit 8aeeaee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container" >
<div *ngIf="(showAttributes | async) == true" class="container" >
<div *ngIf="(verificationToken$ | async) != null">
<h5 class="display-4">{{'clarin.autoregistration.welcome.message' | translate}} {{dspaceName$ | async}}</h5>
<div class="alert alert-info" role="alert" style="width: 100%">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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<boolean> = new BehaviorSubject<boolean>(false);

constructor(protected router: Router,
public route: ActivatedRoute,
private requestService: RequestService,
Expand All @@ -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<ConfigurationProperty>) => {
const stringBoolean = value?.payload?.values?.[0];
this.showAttributes.next(stringBoolean === 'true');
});

if (this.showAttributes.value === false) {
this.sendAutoLoginRequest();
}
}

/**
Expand Down Expand Up @@ -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<any> {
return await this.configurationService.findByPropertyName('authentication-shibboleth.show.idp-attributes')
.pipe(
getFirstCompletedRemoteData()
).toPromise();
}
}
/**
* ShibHeaders string value from the verificationToken$ parsed to the objects.
*/
Expand Down

0 comments on commit 8aeeaee

Please sign in to comment.