[Library]: Fix some issues on guards. Change session is Logged in to check user's token.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57071 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
d0afb3ab36
commit
7955acd2bc
|
@ -34,6 +34,7 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
|
||||||
if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user)) {
|
if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user)) {
|
||||||
return of(true);
|
return of(true);
|
||||||
} else {
|
} else {
|
||||||
|
errorCode = LoginErrorCodes.NOT_ADMIN;
|
||||||
return this.communityService.isCommunityManager(properties, properties['communityAPI'] + community,
|
return this.communityService.isCommunityManager(properties, properties['communityAPI'] + community,
|
||||||
email);
|
email);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,12 @@ export class ConnectSubscriberGuard implements CanActivate {
|
||||||
private propertiesService: EnvironmentSpecificService) {}
|
private propertiesService: EnvironmentSpecificService) {}
|
||||||
|
|
||||||
check(community: string, path: string): Observable<boolean> | boolean {
|
check(community: string, path: string): Observable<boolean> | boolean {
|
||||||
let errorCode = LoginErrorCodes.NOT_SUBSCRIBER;
|
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||||
let email = null;
|
let email = null;
|
||||||
const subscribed = this.propertiesService.subscribeEnvironment().pipe(map(res => res), mergeMap(properties => {
|
const subscribed = this.propertiesService.subscribeEnvironment().pipe(map(res => res), mergeMap(properties => {
|
||||||
return this.userManagementService.getUserInfo(properties.userInfoUrl).pipe(map(user => {
|
return this.userManagementService.getUserInfo(properties.userInfoUrl).pipe(map(user => {
|
||||||
if (user) {
|
if (user) {
|
||||||
|
errorCode = LoginErrorCodes.NOT_SUBSCRIBER;
|
||||||
email = user.email;
|
email = user.email;
|
||||||
let communityDomain = ConnectHelper.getCommunityFromDomain(properties.domain);
|
let communityDomain = ConnectHelper.getCommunityFromDomain(properties.domain);
|
||||||
if(communityDomain) {
|
if(communityDomain) {
|
||||||
|
|
|
@ -35,8 +35,6 @@ export class MailPrefsComponent {
|
||||||
public userValidMessage:string = "";
|
public userValidMessage:string = "";
|
||||||
public savedMessage: string = "";
|
public savedMessage: string = "";
|
||||||
|
|
||||||
public fetchId:string;
|
|
||||||
|
|
||||||
private errorCodes: ErrorCodes;
|
private errorCodes: ErrorCodes;
|
||||||
private errorMessages: ErrorMessagesComponent;
|
private errorMessages: ErrorMessagesComponent;
|
||||||
|
|
||||||
|
@ -58,8 +56,6 @@ export class MailPrefsComponent {
|
||||||
this.communityId = params['communityId'];
|
this.communityId = params['communityId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetchId = Session.getUserEmail();
|
|
||||||
|
|
||||||
this.getEmailPreferences();
|
this.getEmailPreferences();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,7 +25,7 @@ export class Session{
|
||||||
public static isLoggedIn(): boolean {
|
public static isLoggedIn(): boolean {
|
||||||
var loggedIn:boolean = false;
|
var loggedIn:boolean = false;
|
||||||
var user:User = null;
|
var user:User = null;
|
||||||
var cookie= COOKIE.getCookie(COOKIE.cookieName_u);
|
var cookie= COOKIE.getCookie(COOKIE.cookieName_id);
|
||||||
if(cookie == null ||cookie == ""){
|
if(cookie == null ||cookie == ""){
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
|
|
Loading…
Reference in New Issue