[Explore]: Change user login check with user management service.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@57060 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
16b5a1c0fd
commit
1f549eb59b
|
@ -1,13 +1,13 @@
|
|||
import {Component, Directive, ElementRef, Renderer2, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {Component} from '@angular/core';
|
||||
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
|
||||
|
||||
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
||||
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
||||
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
||||
|
||||
import {Session} from './openaireLibrary/login/utils/helper.class';
|
||||
import {Session, User} from './openaireLibrary/login/utils/helper.class';
|
||||
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
||||
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
||||
|
||||
@Component({
|
||||
//changeDetection: ChangeDetectionStrategy.Default,
|
||||
|
@ -17,7 +17,7 @@ import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
|||
`],
|
||||
template: `
|
||||
|
||||
<navbar *ngIf="properties" portal="explore" [properties]=properties [onlyTop]=false
|
||||
<navbar *ngIf="properties && loginCheck" portal="explore" [properties]=properties [onlyTop]=false [user]="user"
|
||||
[communityId]="properties.adminToolsCommunity" [userMenuItems]=userMenuItems [menuItems]=menuItems></navbar>
|
||||
<div class="custom-main-content">
|
||||
<main>
|
||||
|
@ -52,9 +52,11 @@ export class AppComponent {
|
|||
|
||||
feedbackmail: string;
|
||||
properties: EnvProperties;
|
||||
user: User;
|
||||
loginCheck: boolean = false;
|
||||
|
||||
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
||||
private router: Router) {
|
||||
private router: Router, private userManagementService: UserManagementService) {
|
||||
router.events.forEach((event) => {
|
||||
if (event instanceof NavigationStart) {
|
||||
HelperFunctions.scroll();
|
||||
|
@ -77,8 +79,11 @@ export class AppComponent {
|
|||
this.propertiesService.setEnvProperties(es);
|
||||
this.properties = this.propertiesService.envSpecific;
|
||||
this.feedbackmail = this.properties.feedbackmail;
|
||||
this.buildMenu();
|
||||
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
this.loginCheck = true;
|
||||
this.buildMenu();
|
||||
});
|
||||
//console.log(this.properties.loginUrl);
|
||||
}, error => {
|
||||
console.log("App couldn't fetch properties");
|
||||
|
@ -88,7 +93,6 @@ export class AppComponent {
|
|||
}
|
||||
|
||||
buildMenu() {
|
||||
|
||||
this.menuItems = [
|
||||
{
|
||||
rootItem: new MenuItem("search", "Search", "", "/search/find", false, [], ["/search/find"], {}),
|
||||
|
@ -120,12 +124,12 @@ export class AppComponent {
|
|||
new MenuItem("", "Browse all", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], {})]
|
||||
}
|
||||
];
|
||||
if (Session.isPortalAdministrator()) {
|
||||
if (Session.isPortalAdministrator(this.user)) {
|
||||
this.userMenuItems.push(new MenuItem("", "Manage all links", "", "/claims", false, [], ["/claims"], {}));
|
||||
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
|
||||
((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
|
||||
|
||||
} else if (Session.isClaimsCurator()) {
|
||||
} else if (Session.isClaimsCurator(this.user)) {
|
||||
this.userMenuItems.push(new MenuItem("", "Manage all links", "", "/claims", false, [], ["/claims"], {}));
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import {EnvProperties} from '../../openaireLibrary/uti
|
|||
@Component({
|
||||
selector: 'openaire-claims-admin',
|
||||
template: `
|
||||
<claims-admin [claimsInfoURL]=claimsInfoURL>
|
||||
<claims-admin *ngIf="claimsInfoURL && userInfoURL" [claimsInfoURL]=claimsInfoURL [userInfoURL]="userInfoURL">
|
||||
</claims-admin>
|
||||
|
||||
`,
|
||||
|
@ -16,6 +16,7 @@ import {EnvProperties} from '../../openaireLibrary/uti
|
|||
export class OpenaireClaimsAdminComponent {
|
||||
|
||||
claimsInfoURL:string;
|
||||
userInfoURL: string;
|
||||
|
||||
constructor (private route: ActivatedRoute) {
|
||||
|
||||
|
@ -24,7 +25,7 @@ export class OpenaireClaimsAdminComponent {
|
|||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.claimsInfoURL = data.envSpecific.claimsInformationLink;
|
||||
|
||||
this.userInfoURL = data.envSpecific.userInfoUrl;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,14 @@ import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properti
|
|||
@Component({
|
||||
selector: 'openaire-my-claims',
|
||||
template: `
|
||||
<my-claims [claimsInfoURL]=claimsInfoURL>
|
||||
<my-claims *ngIf="userInfoURL && claimsInfoURL" [claimsInfoURL]=claimsInfoURL [userInfoURL]="userInfoURL">
|
||||
</my-claims>
|
||||
`
|
||||
|
||||
})
|
||||
export class OpenaireMyClaimsComponent {
|
||||
claimsInfoURL:string;
|
||||
claimsInfoURL:string;
|
||||
userInfoURL: string;
|
||||
|
||||
constructor (private route: ActivatedRoute) {
|
||||
|
||||
|
@ -23,7 +24,7 @@ import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properti
|
|||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.claimsInfoURL = data.envSpecific.claimsInformationLink;
|
||||
|
||||
this.userInfoURL = data.envSpecific.userInfoUrl;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
"piwikSiteId" : "6",
|
||||
"loginUrl" :"http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login",
|
||||
|
||||
"userInfoUrl" : "http://rudie.di.uoa.gr:8280/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=",
|
||||
|
||||
"logoutUrl" :"https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=",
|
||||
|
||||
"cookieDomain" :".di.uoa.gr",
|
||||
|
|
Loading…
Reference in New Issue