From 0f3a78e7eafa000864f5d9348565d33aedc707e1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 20 Jul 2016 16:40:28 +0200 Subject: Client: Auth services cleanup --- client/src/app/shared/auth/auth-http.service.ts | 2 +- client/src/app/shared/auth/auth.service.ts | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/auth/auth-http.service.ts b/client/src/app/shared/auth/auth-http.service.ts index ff8099a46..9c7ef4389 100644 --- a/client/src/app/shared/auth/auth-http.service.ts +++ b/client/src/app/shared/auth/auth-http.service.ts @@ -72,6 +72,6 @@ export class AuthHttp extends Http { } private setAuthorizationHeader(headers: Headers) { - headers.set('Authorization', `${this.authService.getTokenType()} ${this.authService.getToken()}`); + headers.set('Authorization', this.authService.getRequestHeaderValue()); } } diff --git a/client/src/app/shared/auth/auth.service.ts b/client/src/app/shared/auth/auth.service.ts index 47f7e1368..667fbeb1f 100644 --- a/client/src/app/shared/auth/auth.service.ts +++ b/client/src/app/shared/auth/auth.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Headers, Http, RequestOptions, Response, URLSearchParams } from '@angular/http'; +import { Headers, Http, Response, URLSearchParams } from '@angular/http'; import { Observable } from 'rxjs/Observable'; import { Subject } from 'rxjs/Subject'; @@ -42,25 +42,17 @@ export class AuthService { this.user = User.load(); } - getAuthRequestOptions(): RequestOptions { - return new RequestOptions({ headers: this.getRequestHeader() }); - } - getRefreshToken() { if (this.user === null) return null; return this.user.getRefreshToken(); } - getRequestHeader() { - return new Headers({ 'Authorization': this.getRequestHeaderValue() }); - } - getRequestHeaderValue() { - return `${this.getTokenType()} ${this.getToken()}`; + return `${this.getTokenType()} ${this.getAccessToken()}`; } - getToken() { + getAccessToken() { if (this.user === null) return null; return this.user.getAccessToken(); @@ -77,7 +69,7 @@ export class AuthService { } isLoggedIn() { - if (this.getToken()) { + if (this.getAccessToken()) { return true; } else { return false; @@ -142,7 +134,7 @@ export class AuthService { .catch(this.handleError); } - setStatus(status: AuthStatus) { + private setStatus(status: AuthStatus) { this.loginChanged.next(status); } -- cgit v1.2.3