route permission

This commit is contained in:
Peter Maquiran
2022-04-08 14:23:04 +01:00
parent 1b93cb25eb
commit 450b5b6845
+41 -17
View File
@@ -32,34 +32,58 @@ export class AuthGuard implements CanActivate {
this.router.navigate(['/']); this.router.navigate(['/']);
return false return false
} else { } else {
if(this.p.userPermission(this.p.permissionList.Chat.access) == true){ if(this.p.userPermission(this.p.permissionList.Chat.access) == true) {
this.authService.loginChat(); this.authService.loginChat();
} }
const pathname = window.location.pathname const pathname = window.location.pathname
if(this.p.userPermission(this.p.permissionList.Agenda.access) && pathname.startsWith('/home/agenda')) { if(this.p.userPermission(pathname.startsWith('/home/agenda'))) {
return true;
} else if (this.p.userPermission(this.p.permissionList.Gabinete.access) && pathname.startsWith('/home/gabinete-digital')) {
return true;
}
else if(this.p.userPermission(this.p.permissionList.Chat.access) && pathname.startsWith('/home/chat')) {
return true;
} else if(this.p.userPermission(this.p.permissionList.Actions.access) && pathname.startsWith('/home/publications')) {
return true;
} else if ((this.p.userPermission([this.p.permissionList.Agenda.access]) || this.p.userPermission([this.p.permissionList.Gabinete.access])) && pathname.startsWith('/home/events')) {
if(this.p.permissionList.Agenda.access) {
return true;
} else {
this.router.navigate(['/login']);
return false;
}
} else if ( pathname.startsWith('/home/gabinete-digital')) {
if(this.p.userPermission(this.p.permissionList.Gabinete.access)) {
return true;
} else {
this.router.navigate(['/login']);
return false;
}
}
else if(pathname.startsWith('/home/chat')) {
if(this.p.userPermission(this.p.permissionList.Gabinete.access)) {
return true;
} else {
this.router.navigate(['/login']);
return false;
}
} else if(pathname.startsWith('/home/publications')) {
if(this.p.userPermission(this.p.permissionList.Actions.access)) {
return true
} else {
this.router.navigate(['/login']);
return false
}
} else if (pathname.startsWith('/home/events')) {
if((this.p.userPermission([this.p.permissionList.Agenda.access]) || this.p.userPermission([this.p.permissionList.Gabinete.access]))) {
return true
} else {
this.router.navigate(['/login']);
return false
}
} else if (pathname == '/') { } else if (pathname == '/') {
return true return true
}
else if (this.RouteService.history.length >= 1) {
const pathName = this.RouteService.getLastRouteA()
this.router.navigate([pathName]);
} else { } else {
this.router.navigate(['/']); this.router.navigate(['/login']);
return false
} }
return false;
} }
} }