I have a custom role with the following role definition
CreateRole({
name: "Student",
privileges: [
{
resource: Collection("Courses"),
actions: { read: true },
},
{
resource: Collection("Teachers"),
actions: { read: true },
},
],
membership: [
{
resource: Collection("Students"),
predicate: Query(
Lambda(
"ref",
Equals(Select(["data", "metadata", "role"], Get("ref")), "student")
)
),
},
],
});
When I try to access the documents in the Courses collection using this command
Paginate(Documents(Collection("Courses")), {size: 5})
with a server key, I get the expected result
{
after: [Ref(Collection("Courses"), "277292924206585362")],
data: [
Ref(Collection("Courses"), "277292924206580242"),
Ref(Collection("Courses"), "277292924206581266"),
Ref(Collection("Courses"), "277292924206582290"),
Ref(Collection("Courses"), "277292924206583314"),
Ref(Collection("Courses"), "277292924206584338")
]
}
But when I try using the secret from the custom Student role I get this result
{ data: [] }
Here’s a document sample from the Courses collection
{
"ref": Ref(Collection("Courses"), "277292924206581266"),
"ts": 1600705990003000,
"data": {
"title": "blue Table",
"description": "Enim repellat aut ea optio et et.",
"teachers": [],
"code": "BLU 396",
"availableFor": [],
"creditLoad": 3
}
}
and a document sample from the Students collection
{
"ref": Ref(Collection("Students"), "277362121690317319"),
"ts": 1600771983156000,
"data": {
"metadata": {
"firstName": "Loma",
"lastName": "Glover",
"email": "loma.glover@skulment.edu",
"role": "student",
"currentClass": "Grade 7"
}
}
}