diff --git a/cf_config/nginx.conf b/cf_config/nginx.conf deleted file mode 100644 index 841957f..0000000 --- a/cf_config/nginx.conf +++ /dev/null @@ -1,9 +0,0 @@ -gzip on; -gzip_disable "msie6"; - -gzip_vary on; -gzip_proxied any; -gzip_comp_level 6; -gzip_buffers 16 8k; -gzip_http_version 1.1; -gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 22ec18b..45633aa 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -7,7 +7,7 @@ import {Router} from '@angular/router'; // TODO: filter by not completely filled/no measurements // TODO: validation of samples -// TODO: get rid of chart.js (+moment.js) and lodash +// TODO: get rid of chart.js (+moment.js) @Component({ selector: 'app-root', diff --git a/src/app/services/login.service.ts b/src/app/services/login.service.ts index f4816bc..fd22687 100644 --- a/src/app/services/login.service.ts +++ b/src/app/services/login.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import {ApiService} from './api.service'; -import {ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot} from '@angular/router'; +import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router'; import {LocalStorageService} from 'angular-2-local-storage'; import {Observable} from 'rxjs'; @@ -26,7 +26,8 @@ export class LoginService implements CanActivate { constructor( private api: ApiService, - private storage: LocalStorageService + private storage: LocalStorageService, + private router: Router ) { } @@ -79,23 +80,24 @@ export class LoginService implements CanActivate { canActivate(route: ActivatedRouteSnapshot = null, state: RouterStateSnapshot = null): Observable { return new Observable(observer => { - const pathPermission = this.pathPermissions.find(e => e.path.indexOf(route.url[0].path) >= 0); - if (!pathPermission || this.is(pathPermission.permission)) { // check if level is permitted for path + new Promise(resolve => { if (this.loggedIn === undefined) { this.login().then(res => { - observer.next(res as any); - observer.complete(); + resolve(res); }); } else { - observer.next(this.loggedIn); - observer.complete(); + resolve(this.loggedIn); } - } - else { - observer.next(false); + }).then(res => { + const pathPermission = this.pathPermissions.find(e => e.path.indexOf(route.url[0].path) >= 0); + const ok = res && !pathPermission || this.is(pathPermission.permission); // check if level is permitted for path + observer.next(ok); observer.complete(); - } + if (!ok) { + this.router.navigate(['/']); + } + }); }); }