[angular-16-irish-monitor | DONE | ADDED] Orcid work: add check for consent in case of irish

This commit is contained in:
argirok 2023-12-19 11:54:31 +02:00
parent 677372a332
commit 8f009f3fee
1 changed files with 19 additions and 3 deletions

View File

@ -13,6 +13,7 @@ import {UserManagementService} from "../services/user-management.service";
import {OpenaireEntities} from "../utils/properties/searchFields";
import {FullScreenModalComponent} from "../utils/modal/full-screen-modal/full-screen-modal.component";
import {LogService} from "../utils/log/log.service";
import {UserProfileService} from "../services/userProfile.service";
declare var UIkit: any;
@ -365,7 +366,7 @@ export class OrcidWorkComponent {
public window: any;
public isLoggedIn: boolean = false;
public hasConsent: boolean = false;
public currentAction: string = "";
public hoverAdd: boolean = false;
@ -378,7 +379,7 @@ export class OrcidWorkComponent {
private _router: Router,
private orcidService: OrcidService,
private resultLandingService: ResultLandingService,
private userManagementService: UserManagementService, private _logService: LogService) {
private userManagementService: UserManagementService, private _logService: LogService, private _userProfileService: UserProfileService) {
if (typeof document !== 'undefined') {
this.tokenUrl = properties.orcidTokenURL
+ "client_id=" + properties.orcidClientId
@ -402,6 +403,13 @@ export class OrcidWorkComponent {
}, error => {
this.isLoggedIn = false;
}));
if(properties.adminToolsPortalType == 'irish'){
this.subscriptions.push(this._userProfileService.getUserProfile().subscribe(userProfile => {
this.hasConsent = userProfile.consent;
}, error =>{
this.hasConsent = false;
}));
}
}
ngOnDestroy() {
@ -523,7 +531,15 @@ export class OrcidWorkComponent {
}
});
} else {
if(properties.adminToolsPortalType == 'irish' && !this.hasConsent){
this._router.navigate(['/consent'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
return;
}
if (this.requestGrant) {
this.openGrantModal("Add, delete or edit work in your ORCID record");
} else {