From 83af04e40d6090e731cf7e7f3f0045a2d3020994 Mon Sep 17 00:00:00 2001
From: David Donges <david.donges@mni.thm.de>
Date: Fri, 16 Mar 2018 11:20:28 +0100
Subject: [PATCH] Fix token interceptor

Fixed token interceptor routes requested by users that aren't logged in (e.g. login route) as the token got accessed directly
without checking if the user object is not undefined.
---
 src/app/authentication.interceptor.ts | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/app/authentication.interceptor.ts b/src/app/authentication.interceptor.ts
index 57b5abb58..1185fe4a0 100644
--- a/src/app/authentication.interceptor.ts
+++ b/src/app/authentication.interceptor.ts
@@ -17,9 +17,8 @@ export class AuthenticationInterceptor implements HttpInterceptor {
   }
 
   intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
-    const token = this.authenticationService.getUser().token;
-
-    if (token) {
+    if (this.authenticationService.isLoggedIn()) {
+      const token = this.authenticationService.getToken();
       const cloned = req.clone({
         headers: req.headers.set(AUTH_HEADER_KEY, token)
       });
-- 
GitLab