@Luigi_Servini It said role already exists, so I ran the following instead:
Update(Role("User"), {
name: 'User',
privileges: [
{
resource: Function("NewPost"),
actions: { call: true }
},
{
resource: Collection("posts"),
actions: {
read: true,
write: false,
create: Query(Lambda("values", Equals(Identity(), Select(["data", "author"], Var("values"))))),
delete: false,
history_read: false,
history_write: false,
unrestricted_read: false
}
}
],
membership: { resource: Collection("users") }
})
I still get the same thing
> 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.'
}
]
}
]
}
In hopes of creating a good minimal reproducible example (and also because I used the post
example, mine is a bit different) I removed some other permissions, so now I can’t even Get(Identity())
, so I took the liberty to add this:
{
resource: Collection("users"),
actions: {
read: Query(Lambda("ref", Equals(Identity(), Var("ref"))))
}
},
It didn’t fix it but now I can verify that for a post (that I created when I set the read to true
when I made sure the predicate was the problem) the predicate should be working:
Equals(Identity(), Select(["data", "author"], Get(Ref(Collection("posts"), "271285137980785159"))))
true
If I were to bet, since I’m a beginner, I don’t want to jump to conclusions of grandeur bugs, I probably do some basic stuff wrong that’s taken for granted that everyone does that I don’t .
Is there a way to debug the predicate function to maybe return the Var("values")
? Maybe it’s something else, or maybe the function throws some error, that can’t be seen?
I also tried regenerating the secret for the user, cause I thought maybe it doesn’t update existing tokens, but it didn’t help.