aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/auth
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-07-20 16:40:28 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-07-20 16:40:28 +0200
commit0f3a78e7eafa000864f5d9348565d33aedc707e1 (patch)
tree55d280fc86124efeaec840d7cf4640fbbda4ed4c /client/src/app/shared/auth
parentbd5c83a8cb46eb6da2b25df3b1f6a2a5795d1869 (diff)
downloadPeerTube-0f3a78e7eafa000864f5d9348565d33aedc707e1.tar.gz
PeerTube-0f3a78e7eafa000864f5d9348565d33aedc707e1.tar.zst
PeerTube-0f3a78e7eafa000864f5d9348565d33aedc707e1.zip
Client: Auth services cleanup
Diffstat (limited to 'client/src/app/shared/auth')
-rw-r--r--client/src/app/shared/auth/auth-http.service.ts2
-rw-r--r--client/src/app/shared/auth/auth.service.ts18
2 files changed, 6 insertions, 14 deletions
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