Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Client: Auth services cleanup

Chocobozzz0f3a78e7eafa
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index f53896bcf1..b7a3d7c58c 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -47,7 +47,6 @@ export class AppComponent {
logout() {
this.authService.logout();
- this.authService.setStatus(AuthStatus.LoggedOut);
}
makeFriends() {
diff --git a/client/src/app/shared/auth/auth-http.service.ts b/client/src/app/shared/auth/auth-http.service.ts
index ff8099a463..9c7ef4389d 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 47f7e1368a..667fbeb1f4 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);
}