+
- Manage links
+ Manage links
@@ -32,24 +32,24 @@ import {UserManagementService} from "../../services/user-management.service";
- `,
+ `,
})
export class ClaimsAdminComponent {
- @Input() fetchBy:string;
- @Input() fetchId:string;
- @Input() isConnect:boolean = false;
- @Input() externalPortalUrl:string;
- @Input() claimsInfoURL:string;
+ @Input() fetchBy: string;
+ @Input() fetchId: string;
+ @Input() isConnect: boolean = false;
+ @Input() externalPortalUrl: string;
+ @Input() claimsInfoURL: string;
@Input() userInfoURL: string;
public user: User = null;
- constructor ( private _meta: Meta, private _title: Title,
- private userManagementService: UserManagementService) {
+ constructor(private _meta: Meta, private _title: Title,
+ private userManagementService: UserManagementService) {
var titleConnect = "OpenAIRE Connect | Manage links ";
var title = "OpenAIRE | Manage links ";
- if(this.isConnect) {
+ if (this.isConnect) {
this._title.setTitle(titleConnect);
} else {
this._title.setTitle(title);
@@ -57,11 +57,10 @@ export class ClaimsAdminComponent {
}
+
ngOnInit() {
- if (typeof document !== 'undefined') {
- this.userManagementService.getUserInfo(this.userInfoURL).subscribe(user => {
- this.user = user;
- });
- }
+ this.userManagementService.getUserInfo(this.userInfoURL).subscribe(user => {
+ this.user = user;
+ });
}
}
diff --git a/connect/communityGuard/connectAdminLoginGuard.guard.ts b/connect/communityGuard/connectAdminLoginGuard.guard.ts
index 07426edf..12948ef4 100644
--- a/connect/communityGuard/connectAdminLoginGuard.guard.ts
+++ b/connect/communityGuard/connectAdminLoginGuard.guard.ts
@@ -28,7 +28,7 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
let errorCode = LoginErrorCodes.NOT_LOGIN;
let email = null;
const authorized = this.propertiesService.subscribeEnvironment().pipe(map(res => res), mergeMap(properties => {
- return typeof document !== 'undefined' && this.userManagementService.getUserInfo(properties.userInfoUrl).pipe(map(user => {
+ return this.userManagementService.getUserInfo(properties.userInfoUrl).pipe(map(user => {
if (user) {
email = user.email;
if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user)) {
diff --git a/connect/communityGuard/connectSubscriber.guard.ts b/connect/communityGuard/connectSubscriber.guard.ts
index 58d6e6c5..d2e48b8b 100644
--- a/connect/communityGuard/connectSubscriber.guard.ts
+++ b/connect/communityGuard/connectSubscriber.guard.ts
@@ -21,7 +21,7 @@ export class ConnectSubscriberGuard implements CanActivate {
let errorCode = LoginErrorCodes.NOT_LOGIN;
let email = null;
const subscribed = this.propertiesService.subscribeEnvironment().pipe(map(res => res), mergeMap(properties => {
- return typeof document !== 'undefined' && this.userManagementService.getUserInfo(properties.userInfoUrl).pipe(map(user => {
+ return this.userManagementService.getUserInfo(properties.userInfoUrl).pipe(map(user => {
if (user) {
errorCode = LoginErrorCodes.NOT_SUBSCRIBER;
email = user.email;
diff --git a/connect/communityGuard/isCommunityOrAdmin.ts b/connect/communityGuard/isCommunityOrAdmin.ts
index d3d04d4e..4589a140 100644
--- a/connect/communityGuard/isCommunityOrAdmin.ts
+++ b/connect/communityGuard/isCommunityOrAdmin.ts
@@ -19,7 +19,7 @@ export class IsCommunityOrAdmin implements CanActivate {
return true;
} else {
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
- return typeof document !== 'undefined' && this.userManagementService.getUserInfo(properties['userInfoUrl']).pipe(map(user => {
+ return this.userManagementService.getUserInfo(properties['userInfoUrl']).pipe(map(user => {
return Session.isPortalAdministrator(user);
}));
}));
diff --git a/login/adminLoginGuard.guard.ts b/login/adminLoginGuard.guard.ts
index fe74b5a9..2118b75c 100644
--- a/login/adminLoginGuard.guard.ts
+++ b/login/adminLoginGuard.guard.ts
@@ -26,7 +26,7 @@ export class AdminLoginGuard implements CanActivate{
check(path: string): Observable
{
let errorCode = LoginErrorCodes.NOT_LOGIN;
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
- return typeof document !== 'undefined' && this.userManagementService.getUserInfo(properties['userInfoUrl']).pipe(map( user => {
+ return this.userManagementService.getUserInfo(properties['userInfoUrl']).pipe(map( user => {
if(user) {
errorCode = LoginErrorCodes.NOT_ADMIN;
}
diff --git a/login/claimsCuratorGuard.guard.ts b/login/claimsCuratorGuard.guard.ts
index 3e282c57..c59cf6dd 100644
--- a/login/claimsCuratorGuard.guard.ts
+++ b/login/claimsCuratorGuard.guard.ts
@@ -26,7 +26,7 @@ export class ClaimsCuratorGuard implements CanActivate {
check(path: string): Observable |boolean {
let errorCode = LoginErrorCodes.NOT_LOGIN;
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
- return typeof document !== 'undefined' && this.userManagementService.getUserInfo(properties['userInfoUrl']).pipe(map( user => {
+ return this.userManagementService.getUserInfo(properties['userInfoUrl']).pipe(map( user => {
if(user) {
errorCode = LoginErrorCodes.NOT_ADMIN;
}
diff --git a/services/user-management.service.ts b/services/user-management.service.ts
index a4932ac9..46ebc59c 100644
--- a/services/user-management.service.ts
+++ b/services/user-management.service.ts
@@ -14,7 +14,9 @@ export class UserManagementService {
public getUserInfo(url: string): Observable {
const token = COOKIE.getCookie('AccessToken');
- return this.http.get(url + token).pipe(map(userInfo => {
+ if(!token) {
+ return of(null);
+ } else return this.http.get(url + token).pipe(map(userInfo => {
return this.parseUserInfo(userInfo);
})).pipe(timeout(2000), catchError(() => {
return of(null);
diff --git a/utils/subscribe/subscribe.service.ts b/utils/subscribe/subscribe.service.ts
index 13378b72..fefd96ec 100644
--- a/utils/subscribe/subscribe.service.ts
+++ b/utils/subscribe/subscribe.service.ts
@@ -7,41 +7,45 @@ import {EnvProperties} from "../properties/env-properties";
@Injectable()
export class SubscribeService {
- constructor(private http:HttpClient) {
- }
- getCommunitySubscribers(properties: EnvProperties, pid:string){
- let url = properties.adminToolsAPIURL+ "/community/"+pid+"/subscribers";
- return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
- }
+ constructor(private http: HttpClient) {
+ }
- isSubscribedToCommunity(properties: EnvProperties, pid:string, email:string){
- let url = properties.adminToolsAPIURL + "/community/"+pid+"/subscribers";
- return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
- .pipe(map(res => {
- if(res['status'] && res['status'] != 200) {
- return null;
- }
- if(res['subscribers'] && res['subscribers'] != null){
+ getCommunitySubscribers(properties: EnvProperties, pid: string) {
+ let url = properties.adminToolsAPIURL + "/community/" + pid + "/subscribers";
+ return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
+ }
- for(var i =0; i< res['subscribers'].length; i++ ){
- if(res['subscribers'][i]!=null && res['subscribers'][i].email == email){
- return true;
- }
- }
- }
- return false;
+ isSubscribedToCommunity(properties: EnvProperties, pid: string, email: string) {
+ let url = properties.adminToolsAPIURL + "/community/" + pid + "/subscribers";
+ return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
+ .pipe(map(res => {
+ if (res['status'] && res['status'] != 200) {
+ return null;
+ }
+ if (res['subscribers'] && res['subscribers'] != null) {
- }));
- }
- subscribeToCommunity(pid:string, email:string, url:string){
- let subscriber = {"email":email};
- return this.http.post(url+"/community/"+pid+"/subscribers", JSON.stringify(subscriber), CustomOptions.getAuthOptionsWithBody());
- }
- unSubscribeToCommunity(pid:string, email:string, url:string){
- return this.http.post(url+"/community/"+pid+"/subscribers/delete", JSON.stringify([email]), CustomOptions.getAuthOptionsWithBody());
- }
- getCommunitiesSubscribedTo(properties: EnvProperties, email:string){
- let url = properties.adminToolsAPIURL+"/subscriber/communities?email="+email;
- return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
- }
+ for (var i = 0; i < res['subscribers'].length; i++) {
+ if (res['subscribers'][i] != null && res['subscribers'][i].email == email) {
+ return true;
+ }
+ }
+ }
+ return false;
+
+ }));
+ }
+
+ subscribeToCommunity(pid: string, email: string, url: string) {
+ let subscriber = {"email": email};
+ return this.http.post(url + "/community/" + pid + "/subscribers", JSON.stringify(subscriber), CustomOptions.getAuthOptionsWithBody());
+ }
+
+ unSubscribeToCommunity(pid: string, email: string, url: string) {
+ return this.http.post(url + "/community/" + pid + "/subscribers/delete", JSON.stringify([email]), CustomOptions.getAuthOptionsWithBody());
+ }
+
+ getCommunitiesSubscribedTo(properties: EnvProperties, email: string) {
+ let url = properties.adminToolsAPIURL + "/subscriber/communities?email=" + email;
+ return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
+ }
}