aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/app.component.ts1
-rw-r--r--client/src/app/shared/auth/auth-http.service.ts2
-rw-r--r--client/src/app/shared/auth/auth.service.ts18
3 files changed, 6 insertions, 15 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index f53896bcf..b7a3d7c58 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -47,7 +47,6 @@ export class AppComponent {
47 47
48 logout() { 48 logout() {
49 this.authService.logout(); 49 this.authService.logout();
50 this.authService.setStatus(AuthStatus.LoggedOut);
51 } 50 }
52 51
53 makeFriends() { 52 makeFriends() {
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 {
72 } 72 }
73 73
74 private setAuthorizationHeader(headers: Headers) { 74 private setAuthorizationHeader(headers: Headers) {
75 headers.set('Authorization', `${this.authService.getTokenType()} ${this.authService.getToken()}`); 75 headers.set('Authorization', this.authService.getRequestHeaderValue());
76 } 76 }
77} 77}
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 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Headers, Http, RequestOptions, Response, URLSearchParams } from '@angular/http'; 2import { Headers, Http, Response, URLSearchParams } from '@angular/http';
3import { Observable } from 'rxjs/Observable'; 3import { Observable } from 'rxjs/Observable';
4import { Subject } from 'rxjs/Subject'; 4import { Subject } from 'rxjs/Subject';
5 5
@@ -42,25 +42,17 @@ export class AuthService {
42 this.user = User.load(); 42 this.user = User.load();
43 } 43 }
44 44
45 getAuthRequestOptions(): RequestOptions {
46 return new RequestOptions({ headers: this.getRequestHeader() });
47 }
48
49 getRefreshToken() { 45 getRefreshToken() {
50 if (this.user === null) return null; 46 if (this.user === null) return null;
51 47
52 return this.user.getRefreshToken(); 48 return this.user.getRefreshToken();
53 } 49 }
54 50
55 getRequestHeader() {
56 return new Headers({ 'Authorization': this.getRequestHeaderValue() });
57 }
58
59 getRequestHeaderValue() { 51 getRequestHeaderValue() {
60 return `${this.getTokenType()} ${this.getToken()}`; 52 return `${this.getTokenType()} ${this.getAccessToken()}`;
61 } 53 }
62 54
63 getToken() { 55 getAccessToken() {
64 if (this.user === null) return null; 56 if (this.user === null) return null;
65 57
66 return this.user.getAccessToken(); 58 return this.user.getAccessToken();
@@ -77,7 +69,7 @@ export class AuthService {
77 } 69 }
78 70
79 isLoggedIn() { 71 isLoggedIn() {
80 if (this.getToken()) { 72 if (this.getAccessToken()) {
81 return true; 73 return true;
82 } else { 74 } else {
83 return false; 75 return false;
@@ -142,7 +134,7 @@ export class AuthService {
142 .catch(this.handleError); 134 .catch(this.handleError);
143 } 135 }
144 136
145 setStatus(status: AuthStatus) { 137 private setStatus(status: AuthStatus) {
146 this.loginChanged.next(status); 138 this.loginChanged.next(status);
147 } 139 }
148 140