I have upgraded my parse server from version 4.5.0 to 6.2.1 and noticed that I can't access the email address of the registering user in beforeSave method anymore. This is how I do this:
const email = request.object.get("email");
This is the error message I get after the upgrade:
Error: {"message":"This user is not allowed to query email on class _User","code":119} {"className":"_User","error":{"code":119,"message":"This user is not allowed to query email on class _User"},"triggerType":"beforeSave"}
I have a test suite that - among other tests - creates new users. In beforeSave method of User class I'm verifying that an email address was provided, that it is valid and that it is not used yet. I know that the last check is also made by parse server by default. I would like to keep this checks in beforeSave method for new users (at least the first two). How can I access the email address inside beforeSave method? Providing the master key within save or get calls does not solve the problem.
Best regards Valdes
I've solved this problem on my own. The breaking change leading to above error came in with parse server version 4.10.14. In the same version there are already integrated checks like is the email address already in use and whether the email address entered is valid. So I have removed this two checks from my cloud code. The only thing I still check is whether an email address was provided. I do it this way:
if (!request.object.has("email")) {
throw new Parse.Error(1234, "Cannot sign up user without an email address");
}
So there is no need to read the email address anymore.