I have a custom validation function in cloud code, it checks the user is a member certain roles, but following the documentation it suggests, doing this
But if the user isn’t admin, the throw “unauthorised” crashes my node app. I assume its because there is no catch block, but returning anything from the validationFunction means the cloud code will run, im a bit baffled as to how you use it? In the example it also shows checking the user against a hard coded userId, thats pretty useless for most circumstances, I use a Role search to check the user has rights, is this wrong?
I guess it is something related to the isAdmin var. Looking at the code you shared, I don’t see where this var is being set. I see also some syntax errors.
I don’t have any problem here, if the user is admin or staff it’ll find them and return, which allows the cloud code to run, my question is, what do I do if they are a user, but not admin or staff, in the example in the docs the code throws an error, but if I do that it crashes my node app. What should I return to the cloud code to stop it from running, but not crashing the app?