move dsl's to rhailib wip

This commit is contained in:
Timur Gordon
2025-06-24 19:23:27 +02:00
parent e2640b9421
commit cd2557c1c3
12 changed files with 161 additions and 65 deletions

View File

@@ -87,16 +87,16 @@ impl Access {
pub fn can_access_resource(
db: Arc<OurDB>,
public_key: &str,
_resource_id_to_check: u32,
_resource_type_to_check: &str,
object_id: u32,
_object_type: &str,
) -> bool {
// Query for Access records matching the public key.
// Note: This fetches all access records for the user. For performance with many records,
// consider a more specific query if your DB supports it, or caching.
println!("Checking access for public key: {}", public_key);
// get all access records for object
let access_records = match db
.collection::<Access>()
.expect("Failed to get Access collection")
.get::<access_index::circle_pk, _>(public_key)
.get::<access_index::object_id, _>(&object_id)
{
Ok(records) => records,
Err(_e) => {
@@ -107,9 +107,8 @@ pub fn can_access_resource(
}
};
if !access_records.is_empty() {
return true;
}
println!("Access records: {:#?}", access_records);
false // Default to deny if no grant is found
// if circle_pk is in access records true
return access_records.iter().any(|record| record.circle_pk == public_key)
}