akveo / akveo/nebular

Using accessChecker on parameterized path

Đang mở
#2,559 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
8.1k
Fork
1.5k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 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",
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.