Fix Bug 2380:Static Inactive session timeout for a user
[osm/NG-UI.git] / src / services / AuthGuardService.ts
index 2effeca..05d3a1e 100644 (file)
@@ -30,6 +30,7 @@ import { map } from 'rxjs/operators';
  * @Injectable takes a metadata object that tells Angular how to compile and run module code
  */
 @Injectable()
+// eslint-disable-next-line deprecation/deprecation
 export class AuthGuardService implements CanActivate {
     /** Holds teh instance of AuthService class of type AuthService @private */
     private router: Router;
@@ -45,15 +46,19 @@ export class AuthGuardService implements CanActivate {
      * Returns Observable<boolean> if authorized @public
      */
     public canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
+        // eslint-disable-next-line deprecation/deprecation
         return combineLatest(
             this.authService.isLoggedIn,
-            this.authService.isChangePassword
+            this.authService.isChangePassword,
+            this.authService.isForgotPassword
         ).pipe(
-            map(([isLoggedIn, changePassword]: [boolean, boolean]): boolean => {
-                if (changePassword || isLoggedIn) {
+            map(([isLoggedIn, changePassword, forgotPassword]: [boolean, boolean, boolean]): boolean => {
+                if (changePassword || isLoggedIn || forgotPassword) {
                     return true;
                 } else {
-                    this.router.navigate(['/login']).catch();
+                    this.router.navigate(['/login']).catch((): void => {
+                        // Catch Navigation Error
+                    });
                     this.authService.destoryToken();
                     return false;
                 }