docs: NEXT_SESSION.md - Permission System todo for next session
This commit is contained in:
@@ -55,3 +55,58 @@ DB_HOST=127.0.0.1 ./vendor/bin/pest
|
|||||||
---
|
---
|
||||||
|
|
||||||
*Commit ngay lập tức trước khi tắt máy!*
|
*Commit ngay lập tức trước khi tắt máy!*
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## PHIÊN TIẾP THEO - PHÂN QUYỀN (CÒN DỞ)
|
||||||
|
|
||||||
|
### Đã có:
|
||||||
|
- [x] Migration: permission_modules, role_templates, users columns
|
||||||
|
- [x] Models: PermissionModule, RoleTemplate
|
||||||
|
- [x] Command: `php artisan permissions:sync`
|
||||||
|
- [x] User Model: getEffectivePermissions(), hasEffectivePermission(), can() override
|
||||||
|
- [x] RoleTemplateResource: Form + Table + Pages (UI tạo mẫu nhóm)
|
||||||
|
- [x] UserResource: Form + Table + Pages (UI gán quyền user)
|
||||||
|
- [x] permissionActions trong 10 Resource
|
||||||
|
|
||||||
|
### CHƯA CÓ (Ưu tiên):
|
||||||
|
1. [ ] Áp dụng can() checks vào TẤT CẢ Resource
|
||||||
|
- Chưa có canViewAny(), canCreate(), canEdit(), canDelete()... trong Resource
|
||||||
|
- Cần thêm vào hoặc tạo base trait để auto check
|
||||||
|
- Hiện tại tất cả user vẫn full quyền!
|
||||||
|
|
||||||
|
2. [ ] Tạo seeder/sample data cho role_templates
|
||||||
|
- Admin: full quyền
|
||||||
|
- Sales: contracts CRUD, customers CRUD, products view
|
||||||
|
- Kế toán: payments CRUD, contracts view, reports view
|
||||||
|
|
||||||
|
3. [ ] Test User::can() override hoạt động đúng
|
||||||
|
- Login → tính effective permissions → lưu session
|
||||||
|
- Logout → xóa session
|
||||||
|
- can('contracts.create') → true/false đúng
|
||||||
|
|
||||||
|
### Cách áp dụng can() vào Resource (gợi ý):
|
||||||
|
```php
|
||||||
|
// Trong mỗi Resource class
|
||||||
|
public static function canViewAny(): bool
|
||||||
|
{
|
||||||
|
return auth()->user()?->can('contracts.view') ?? false;
|
||||||
|
}
|
||||||
|
public static function canCreate(): bool
|
||||||
|
{
|
||||||
|
return auth()->user()?->can('contracts.create') ?? false;
|
||||||
|
}
|
||||||
|
public static function canEdit($record): bool
|
||||||
|
{
|
||||||
|
return auth()->user()?->can('contracts.update') ?? false;
|
||||||
|
}
|
||||||
|
public static function canDelete($record): bool
|
||||||
|
{
|
||||||
|
return auth()->user()?->can('contracts.delete') ?? false;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lưu ý:
|
||||||
|
- Không chạy `php artisan permissions:sync` tự động (chạy tay khi thêm module)
|
||||||
|
- Action mới mặc định TẮT
|
||||||
|
- Layout RoleTemplateForm đã fix full width
|
||||||
|
|||||||
Reference in New Issue
Block a user