[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)) {
|
||||
return of(true);
|
||||
} else {
|
||||
errorCode = LoginErrorCodes.NOT_ADMIN;
|
||||
return this.communityService.isCommunityManager(properties, properties['communityAPI'] + community,
|
||||
email);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,12 @@ export class ConnectSubscriberGuard implements CanActivate {
|
|||
private propertiesService: EnvironmentSpecificService) {}
|
||||
|
||||
check(community: string, path: string): Observable<boolean> | boolean {
|
||||
let errorCode = LoginErrorCodes.NOT_SUBSCRIBER;
|
||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
let email = null;
|
||||
const subscribed = this.propertiesService.subscribeEnvironment().pipe(map(res => res), mergeMap(properties => {
|
||||
return this.userManagementService.getUserInfo(properties.userInfoUrl).pipe(map(user => {
|
||||
if (user) {
|
||||
errorCode = LoginErrorCodes.NOT_SUBSCRIBER;
|
||||
email = user.email;
|
||||
let communityDomain = ConnectHelper.getCommunityFromDomain(properties.domain);
|
||||
if(communityDomain) {
|
||||
|
|
|
@ -35,8 +35,6 @@ export class MailPrefsComponent {
|
|||
public userValidMessage:string = "";
|
||||
public savedMessage: string = "";
|
||||
|
||||
public fetchId:string;
|
||||
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
|
||||
|
@ -58,8 +56,6 @@ export class MailPrefsComponent {
|
|||
this.communityId = params['communityId'];
|
||||
}
|
||||
|
||||
this.fetchId = Session.getUserEmail();
|
||||
|
||||
this.getEmailPreferences();
|
||||
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ export class Session{
|
|||
public static isLoggedIn(): boolean {
|
||||
var loggedIn:boolean = false;
|
||||
var user:User = null;
|
||||
var cookie= COOKIE.getCookie(COOKIE.cookieName_u);
|
||||
var cookie= COOKIE.getCookie(COOKIE.cookieName_id);
|
||||
if(cookie == null ||cookie == ""){
|
||||
return false;
|
||||
}else{
|
||||
|
|
Loading…
Reference in New Issue