Skip to content
Snippets Groups Projects
Commit 141442d9 authored by Baptiste Toulemonde's avatar Baptiste Toulemonde
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://git.garr.it/eosc-pillar/ffds/ffds-register-front into feature/mapping
parents 05cc3729 c8cc2d17
No related branches found
No related tags found
1 merge request!7delete fdp & smartharvester settings: config from environement and get user...
...@@ -24,6 +24,9 @@ export class TokenStorageService { ...@@ -24,6 +24,9 @@ export class TokenStorageService {
public getToken(): string { public getToken(): string {
return window.sessionStorage.getItem(TOKEN_KEY); return window.sessionStorage.getItem(TOKEN_KEY);
} }
public getFDPToken(): string {
return window.sessionStorage.getItem(F2DS_TOKEN_KEY);
}
public saveUser(user): void { public saveUser(user): void {
window.sessionStorage.removeItem(USER_KEY); window.sessionStorage.removeItem(USER_KEY);
......
...@@ -61,11 +61,11 @@ export class PublishRepositoryService { ...@@ -61,11 +61,11 @@ export class PublishRepositoryService {
} }
async addUserCatalog(catId: string): Promise<any> { async addUserCatalog(catId: string): Promise<any> {
const tokenResponse = await this.authService.getF2DSAuthToken().toPromise(); const tokenResponse = this.tokenService.getToken;
const user = this.tokenService.getUser(); const user = this.tokenService.getUser();
return this.http.post(this.smartApiUrl + '/user/' + user.email + '/catalogs', catId, return this.http.post(this.smartApiUrl + '/user/' + user.email + '/catalogs', catId,
{ headers: { Authorization: 'Bearer ' + tokenResponse.token } }) { headers: { Authorization: 'Bearer ' + tokenResponse } })
.toPromise(); .toPromise();
} }
......
import { HttpClient } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AppConfiguration } from '../AppConfiguration'; import { AppConfiguration } from '../AppConfiguration';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
...@@ -22,6 +22,17 @@ export interface FdpApiResponseItem { ...@@ -22,6 +22,17 @@ export interface FdpApiResponseItem {
}) })
export class CatalogService { export class CatalogService {
httpOptionsSmartHarvester = {
headers: new HttpHeaders({
'Authorization': 'Bearer '+ this.tokenService.getToken()
})
};
httpOptionsFDP = {
headers: new HttpHeaders({
'Authorization': 'Bearer '+ this.tokenService.getFDPToken()
})
};
constructor( constructor(
private appConfig: AppConfiguration, private appConfig: AppConfiguration,
private tokenService: TokenStorageService, private tokenService: TokenStorageService,
...@@ -34,10 +45,10 @@ export class CatalogService { ...@@ -34,10 +45,10 @@ export class CatalogService {
getAllCatalogId() { getAllCatalogId() {
const user = this.tokenService.getUser(); const user = this.tokenService.getUser();
return this.http.get<{ catId: string, uuid: string }[]>(this.smartApiUrl + '/user/' + user.email + '/catalogs'); return this.http.get<{ catId: string, uuid: string }[]>(this.smartApiUrl + '/user/' + user.email + '/catalogs', this.httpOptionsSmartHarvester);
} }
getCatalogContentById(catId: string) { getCatalogContentById(catId: string) {
return this.http.get<FdpApiResponseItem[]>(this.appConfig.fdpurl + '/catalog/' + catId); return this.http.get<FdpApiResponseItem[]>(this.appConfig.fdpurl + '/catalog/' + catId, this.httpOptionsFDP);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment