I’m getting a permission denied error when the predicate is set, but it’s all ok when I set it to a boolean true
. Don’t know what’s wrong. Here’s the details:
I have a post with an author which I create/update in the following way:
Update(Function("NewPost"), {
body: Query(
Lambda(
[],
Create(Collection("posts"), {
data: {
author: Identity(),
},
}),
)
)
}
),
But when I try to call this function I get:
Call("NewPost")
Error: call error
{
errors: [
{
position: [],
code: 'call error',
description: 'Calling the function resulted in an error.',
cause: [
{
position: [
'expr',
'in',
'create'
],
code: 'permission denied',
description: 'Insufficient privileges to perform the action.'
}
]
}
]
}
My permissions are as follows:
{
ref: Role("User"),
ts: 1594976677881800,
name: 'User',
privileges: [
{
resource: Function("NewPost"),
actions: { call: true }
},
{
resource: Collection("posts"),
actions: {
read: true,
write: false,
create: Query(Lambda("values", Equals(Identity(null), Select(["data", "author"], Var("values"))))),
delete: false,
history_read: false,
history_write: false,
unrestricted_read: false
}
}
],
membership: [ { resource: Collection("users") } ]
}
The problem must be the create
action predicate, since it works fine when I set it to true
.
I check this manually:
Equals(Identity(), Select(["data", "author"], Get(Ref(Collection("posts"), "2179812749812749812794"))))
and it returns true
. So I don’t know why the predicate fails.
I tried removing the null
parameter from the Identity
function, but it didn’t help. I also tried accessing the data by just using ["author"]
and not ["data", "author"]
, also didn’t help.
I don’t know what’s wrong here. I’d appreciate any help.