Skip to content

Commit

Permalink
fix(context): pass object to service instead of json.stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Mar 15, 2021
1 parent 72c51d0 commit 2a54c62
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
14 changes: 7 additions & 7 deletions packages/auth/src/lib/shared/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ export class AuthService {
}

login(username: string, password: string): Observable<void> {
const myHeader = new HttpHeaders({'Content-Type': 'application/json'});
const myHeader = new HttpHeaders({ 'Content-Type': 'application/json' });

const body = JSON.stringify({
const body = {
username,
password: this.encodePassword(password)
});
};

return this.loginCall(body, myHeader);
}

loginWithToken(token: string, type: string): Observable<void> {
const myHeader = new HttpHeaders({'Content-Type': 'application/json'});
const myHeader = new HttpHeaders({ 'Content-Type': 'application/json' });

const body = JSON.stringify({
const body = {
token,
typeConnection: type
});
};

return this.loginCall(body, myHeader);
}
Expand Down Expand Up @@ -126,7 +126,7 @@ export class AuthService {

updateUser(user: User): Observable<User> {
const url = this.config.getConfig('auth.url');
return this.http.patch<User>(url, JSON.stringify(user));
return this.http.patch<User>(url, user);
}

private encodePassword(password: string) {
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/lib/image/secure-image.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export class SecureImagePipe implements PipeTransform {
transform(url: string): Observable<string> {
const headers = new HttpHeaders({
'Content-Type': 'text/plain',
'activityInterceptor': 'false'
activityInterceptor: 'false'
});

return this.http
.get(url, {
headers: headers,
headers,
responseType: 'blob'
})
.pipe(
Expand Down
20 changes: 9 additions & 11 deletions packages/context/src/lib/context-manager/shared/context.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class ContextService {

create(context: DetailedContext): Observable<Context> {
const url = this.baseUrl + '/contexts';
return this.http.post<Context>(url, JSON.stringify(context)).pipe(
return this.http.post<Context>(url, context).pipe(
map((contextCreated) => {
if (this.authService.authenticated) {
contextCreated.permission = TypePermission[TypePermission.write];
Expand All @@ -197,7 +197,7 @@ export class ContextService {

clone(id: string, properties = {}): Observable<Context> {
const url = this.baseUrl + '/contexts/' + id + '/clone';
return this.http.post<Context>(url, JSON.stringify(properties)).pipe(
return this.http.post<Context>(url, properties).pipe(
map((contextCloned) => {
contextCloned.permission = TypePermission[TypePermission.write];
this.contexts$.value.ours.unshift(contextCloned);
Expand All @@ -209,7 +209,7 @@ export class ContextService {

update(id: string, context: Context): Observable<Context> {
const url = this.baseUrl + '/contexts/' + id;
return this.http.patch<Context>(url, JSON.stringify(context));
return this.http.patch<Context>(url, context);
}

// =================================================================
Expand All @@ -219,7 +219,7 @@ export class ContextService {
const association = {
toolId
};
return this.http.post<void>(url, JSON.stringify(association));
return this.http.post<void>(url, association);
}

deleteToolAssociation(contextId: string, toolId: string): Observable<any> {
Expand All @@ -243,13 +243,11 @@ export class ContextService {
typePermission: type
};

return this.http
.post<ContextPermission[]>(url, JSON.stringify(association))
.pipe(
catchError((res) => {
return [this.handleError(res, undefined, true)];
})
);
return this.http.post<ContextPermission[]>(url, association).pipe(
catchError((res) => {
return [this.handleError(res, undefined, true)];
})
);
}

deletePermissionAssociation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ export class PoiService {

create(context: Poi): Observable<Poi> {
const url = this.baseUrl + '/pois';
return this.http.post<Poi>(url, JSON.stringify(context));
return this.http.post<Poi>(url, context);
}
}

0 comments on commit 2a54c62

Please sign in to comment.