Blacked and isorted the python files

Prettied and eslinted the typescript/html files
This commit is contained in:
2020-10-11 10:56:29 +05:30
parent b31db593c2
commit d677cfb1ea
505 changed files with 7560 additions and 5650 deletions

View File

@ -1,26 +1,27 @@
import { Injectable } from '@angular/core';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { AuthService } from './auth.service';
import { ToasterService } from '../core/toaster.service';
@Injectable({providedIn: 'root'})
import { AuthService } from './auth.service';
@Injectable({ providedIn: 'root' })
export class AuthGuard implements CanActivate {
constructor(
private router: Router,
private authService: AuthService,
private toaster: ToasterService
) {
}
private toaster: ToasterService,
) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const user = this.authService.user;
const permission = (route.data['permission'] === undefined) ? route.data['permission'] : route.data['permission']
.replace(/ /g, '-')
.toLowerCase();
const { user } = this.authService;
const permission =
route.data.permission === undefined
? route.data.permission
: route.data.permission.replace(/ /g, '-').toLowerCase();
if (!user) {
// not logged in so redirect to login page with the return url
this.router.navigate(['/login'], {queryParams: {returnUrl: state.url}});
this.router.navigate(['/login'], { queryParams: { returnUrl: state.url } });
return false;
}
if (permission !== undefined && user.perms.indexOf(permission) === -1) {
@ -29,6 +30,5 @@ export class AuthGuard implements CanActivate {
}
// logged in so return true
return true;
}
}