aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/auth/auth.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/auth/auth.service.ts')
-rw-r--r--client/src/app/shared/auth/auth.service.ts18
1 files changed, 5 insertions, 13 deletions
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