check method
Implementation
Future<bool?> check(Query query) async {
if (query.allowAll) return true;
if (query.token == null) throw Exception('Token Must Not Be Null');
if (!query.token!.isDecrypted) await query.token!.decryptToken();
//TODO: Starts with * : so implement chat doc
if (query.collection!.startsWith("_")) {
return query.token!.authType == AuthType.admin;
}
// if (query.operationType == null) {
// throw Exception('Query Type Must Not be null');
// }
if (query.operationType == DbOperationType.update) {
// ignore: unnecessary_null_comparison
if (resource == null) {
throw Exception('Resource Data must not be null in update query');
}
} else if (query.operationType == DbOperationType.delete) {
// ignore: unnecessary_null_comparison
if (resource == null) {
throw Exception('Resource Data must not be null in update query');
}
} else if (!(query.operationType == DbOperationType.read ||
query.operationType == DbOperationType.create)) {
throw Exception(
'Query Type must be [create] or [delete] or [update] or [read]');
}
return _checkRule(query);
}