Consider the following scenario.
Iāve two classes:
-
tokens : this is the target of an EventSync which store all new token minted. I provide only āwriteā permission to ācoreservicesā
-
CLASS_A: this is another class; I want this class to be modified (give āwriteā permission) only through a cloud function triggered after a new item has been added to tokens
Therefore, I write a cloud function like:
Moralis.Cloud.afterSave("tokens", async (request) => {
const Ref = Moralis.Object.extend("CLASS_A");
const newItem = new Ref();
await newItem.save(data)
})
My point is: how to manage the CLPs of CLASS_A
My first idea was to give to CLASS_A the permission to ācoreservicesā (like for tokens). However, this seems not working.
I know a workaround is to use the masterkey:
await newItem.save(data,{ useMasterKey: true })
is this the right approach in your opiniono?
Isnāt there a way to create a role for a cloud function (like we do for users)?
Thank you, I appreciate any suggestion