From 64b0790a0d7cc19b643c9ecfca4161b14e9caccf Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Mon, 9 Jul 2018 22:20:13 +0300 Subject: [PATCH] [ACA-1543] Quick Share - Non-logged user can't see the content of a shared file (#503) * resolve guard * lint * fix errors --- .../services/experimental-guard.service.ts | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/app/common/services/experimental-guard.service.ts b/src/app/common/services/experimental-guard.service.ts index 5750f5fa4..237541cb7 100644 --- a/src/app/common/services/experimental-guard.service.ts +++ b/src/app/common/services/experimental-guard.service.ts @@ -1,20 +1,35 @@ -import { CanActivate, ActivatedRouteSnapshot } from '@angular/router'; +import { CanActivate, ActivatedRouteSnapshot, Router } from '@angular/router'; import { Injectable } from '@angular/core'; -import { AppConfigService } from '@alfresco/adf-core'; +import { AppConfigService, StorageService } from '@alfresco/adf-core'; import { environment } from '../../../environments/environment'; @Injectable() export class ExperimentalGuard implements CanActivate { - constructor(private config: AppConfigService) {} + constructor( + private config: AppConfigService, + private storage: StorageService, + private router: Router + ) {} canActivate(route: ActivatedRouteSnapshot) { const key = `experimental.${route.data.ifExperimentalKey}`; const value = this.config.get(key); + const override = this.storage.getItem(key); + + if (override === 'true') { + return true; + } if (!environment.production) { - return value === true || value === 'true'; + if (value === true || value === 'true') { + return true; + } + + this.router.navigate(['/']); } + this.router.navigate(['/']); + return false; } }