[ACA-1543] Quick Share - Non-logged user can't see the content of a shared file (#503)

* resolve guard

* lint

* fix errors
This commit is contained in:
Cilibiu Bogdan
2018-07-09 20:20:12 +01:00
committed by Denys Vuika
parent 382b459ac8
commit 64b0790a0d
@@ -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;
}
}