This commit is contained in:
Arseni
2025-12-16 18:21:49 +03:00
parent 6ee146b95a
commit a2c05745ad
12 changed files with 180 additions and 88 deletions

View File

@@ -52,7 +52,11 @@ class PermissionsProvider extends ChangeNotifier {
}
/// Load the [UserAccess] for the current venue.
Future<UserAccess?> load() async {
Future<UserAccess?> load() async {
if (!_organizations.isOrganizationSet) {
// Organization is not ready yet; skip loading until it becomes available.
return _userAccess.data;
}
_userAccess = _userAccess.copyWith(isLoading: true, error: null);
notifyListeners();
@@ -179,6 +183,10 @@ class PermissionsProvider extends ChangeNotifier {
notifyListeners();
}
Future<void> resetAsync() async {
reset();
}
bool canRead(ResourceType r, {Object? objectRef}) => canAccessResource(r, action: perm.Action.read, objectRef: objectRef);
bool canUpdate(ResourceType r, {Object? objectRef}) => canAccessResource(r, action: perm.Action.update, objectRef: objectRef);
bool canDelete(ResourceType r, {Object? objectRef}) => canAccessResource(r, action: perm.Action.delete, objectRef: objectRef);