Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ufal/fe-not-show-shib-welcome-page #431

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading