Using accessChecker on parameterized path
- Linguagem predominante
- TypeScript
- Estrelas
- 8.1k
- Forks
- 1.5k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
### Issue type
**I'm submitting a ...** (check one with "x")
* [x] bug report
* [ ] feature request
### Issue description
I'm using `accessChecker.isGranted()` method in `canActivate()` to check whether the user has access to the route, this doesn't work for route where I pass parameters.
**Current behavior:** `accessChecker.isGranted(permission, resource)` returns `false` on parameterized route path
**Expected behavior:** Detect if path has `parameter`, if yes enable the route.
**Steps to reproduce:**
app.module.ts
NbSecurityModule.forRoot({
accessControl: {
guest: {
view: ['news'],
}
}})
app.routing.ts
const routes: Routes = [
...
{ path: 'news/:newsID', component: BookDetailsComponent, canActivate: [RouteGuard] },
...
];
route.guard.ts
canActivate(...) {
returns this.accessChecker.isGranted('view', route.routeConfig.path).pipe(
map(resolve => {
if(resolve) {
return resolve;
}else{
this.router.navigate(['auth/login']);
return false;
}
}
);
}
### Other information:
**Angular, Nebular**
```
"@angular/common": "~10.1.4",
"@angular/compiler": "~10.1.4",
"@angular/core": "~10.1.4",
"@nebular/auth": "^6.2.1",
"@nebular/eva-icons": "6.2.1",
"@nebular/security": "^6.2.1",
"@nebular/theme": "^6.2.1",
```
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.