From abb8fc1677a2fadd8d89f15b84ce4a2f91609ebd Mon Sep 17 00:00:00 2001
From: Giuseppe Digilio <giuseppe.digilio@4science.it>
Date: Thu, 1 Mar 2018 11:50:40 +0100
Subject: [PATCH] Added comment

---
 src/app/core/auth/auth-request.service.ts |  7 +------
 src/app/core/auth/auth.service.ts         | 14 ++++++++------
 src/app/core/data/request.service.ts      |  1 +
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/app/core/auth/auth-request.service.ts b/src/app/core/auth/auth-request.service.ts
index 6791100d40..3255d62d21 100644
--- a/src/app/core/auth/auth-request.service.ts
+++ b/src/app/core/auth/auth-request.service.ts
@@ -16,12 +16,6 @@ export class AuthRequestService extends HALEndpointService {
   protected linkName = 'authn';
   protected browseEndpoint = '';
 
-  /**
-   * True if authenticated
-   * @type
-   */
-  private _authenticated = false;
-
   constructor(protected responseCache: ResponseCacheService,
               protected requestService: RequestService,
               @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig) {
@@ -31,6 +25,7 @@ export class AuthRequestService extends HALEndpointService {
   protected fetchRequest(request: RestRequest): Observable<any> {
     const [successResponse, errorResponse] = this.responseCache.get(request.href)
       .map((entry: ResponseCacheEntry) => entry.response)
+      // TODO to review when https://github.com/DSpace/dspace-angular/issues/217 will be fixed
       .do(() => this.responseCache.remove(request.href))
       .partition((response: RestResponse) => response.isSuccessful);
     return Observable.merge(
diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts
index 58e4ac8dd8..1bde30d9aa 100644
--- a/src/app/core/auth/auth.service.ts
+++ b/src/app/core/auth/auth.service.ts
@@ -1,7 +1,7 @@
 import { Injectable } from '@angular/core';
 
 import { Observable } from 'rxjs/Observable';
-import { filter, map, withLatestFrom } from 'rxjs/operators';
+import { map, withLatestFrom } from 'rxjs/operators';
 
 import { Eperson } from '../eperson/models/eperson.model';
 import { AuthRequestService } from './auth-request.service';
@@ -20,6 +20,7 @@ import { Router } from '@angular/router';
 import { CookieAttributes } from 'js-cookie';
 
 export const LOGIN_ROUTE = '/login';
+
 /**
  * The auth service.
  */
@@ -43,7 +44,7 @@ export class AuthService {
     // If current route is different from the one setted in authentication guard
     // and is not the login route, clear redirect url and messages
     const routeUrlObs = this.store.select(routerStateSelector)
-      .filter((routerState: RouterReducerState) => isNotUndefined(routerState) && isNotUndefined(routerState.state) )
+      .filter((routerState: RouterReducerState) => isNotUndefined(routerState) && isNotUndefined(routerState.state))
       .filter((routerState: RouterReducerState) => (routerState.state.url !== LOGIN_ROUTE))
       .map((routerState: RouterReducerState) => routerState.state.url);
     const redirectUrlObs = this.getRedirectUrl();
@@ -52,8 +53,8 @@ export class AuthService {
       map(([routeUrl, redirectUrl]) => [routeUrl, redirectUrl])
     ).filter(([routeUrl, redirectUrl]) => isNotEmpty(redirectUrl) && (routeUrl !== redirectUrl))
       .subscribe(() => {
-      this.setRedirectUrl('');
-    });
+        this.setRedirectUrl('');
+      });
   }
 
   /**
@@ -202,7 +203,7 @@ export class AuthService {
   }
 
   /**
-   * Check if a token is about to expire
+   * Check if a token is next to be expired
    * @returns {boolean}
    */
   public isTokenExpiring(): Observable<boolean> {
@@ -226,6 +227,7 @@ export class AuthService {
     const token = this.getToken();
     return token && token.expires < Date.now();
   }
+
   /**
    * Save authentication token info
    *
@@ -234,7 +236,7 @@ export class AuthService {
    */
   public storeToken(token: AuthTokenInfo) {
     const expires = new Date(token.expires);
-    const options: CookieAttributes = { expires: expires };
+    const options: CookieAttributes = {expires: expires};
     return this.storage.set(TOKENITEM, token, options);
   }
 
diff --git a/src/app/core/data/request.service.ts b/src/app/core/data/request.service.ts
index 7952c736d3..fa33eb47e6 100644
--- a/src/app/core/data/request.service.ts
+++ b/src/app/core/data/request.service.ts
@@ -67,6 +67,7 @@ export class RequestService {
       .flatMap((uuid: string) => this.getByUUID(uuid));
   }
 
+  // TODO to review "overrideRequest" param when https://github.com/DSpace/dspace-angular/issues/217 will be fixed
   configure<T extends CacheableObject>(request: RestRequest, overrideRequest: boolean = false): void {
     if (request.method !== RestRequestMethod.Get || !this.isCachedOrPending(request) || overrideRequest) {
       this.dispatchRequest(request, overrideRequest);
-- 
GitLab