From bd5c83a8cb46eb6da2b25df3b1f6a2a5795d1869 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 20 Jul 2016 16:24:18 +0200 Subject: Client: Add authHttp service that authentificates the http request and optionally refresh the access token if needed --- client/src/app/friends/friend.service.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'client/src/app/friends') diff --git a/client/src/app/friends/friend.service.ts b/client/src/app/friends/friend.service.ts index f956a5ece..771046484 100644 --- a/client/src/app/friends/friend.service.ts +++ b/client/src/app/friends/friend.service.ts @@ -1,25 +1,23 @@ import { Injectable } from '@angular/core'; -import { Http, Response } from '@angular/http'; +import { Response } from '@angular/http'; import { Observable } from 'rxjs/Observable'; -import { AuthService } from '../shared'; +import { AuthHttp, AuthService } from '../shared'; @Injectable() export class FriendService { private static BASE_FRIEND_URL: string = '/api/v1/pods/'; - constructor (private http: Http, private authService: AuthService) {} + constructor (private authHttp: AuthHttp, private authService: AuthService) {} makeFriends() { - const headers = this.authService.getRequestHeader(); - return this.http.get(FriendService.BASE_FRIEND_URL + 'makefriends', { headers }) + return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'makefriends') .map(res => res.status) .catch(this.handleError); } quitFriends() { - const headers = this.authService.getRequestHeader(); - return this.http.get(FriendService.BASE_FRIEND_URL + 'quitfriends', { headers }) + return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends') .map(res => res.status) .catch(this.handleError); } -- cgit v1.2.3