英文:
Access email address during user registration in parse server
问题
我已将我的解析服务器从版本4.5.0升级到6.2.1,并注意到我不能再在beforeSave方法中访问注册用户的电子邮件地址了。我是这样做的:
const email = request.object.get("email");
这是升级后我收到的错误消息:
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"}
我有一个测试套件,其中包括创建新用户的测试。在User类的beforeSave方法中,我正在验证是否提供了电子邮件地址,它是否有效,以及它是否尚未使用。我知道解析服务器默认也会进行最后一项检查。我想在beforeSave方法中保留新用户的这些检查(至少前两项)。如何在beforeSave方法中访问电子邮件地址?在保存或获取调用中提供主密钥并不能解决这个问题。
最好的问候,
Valdes
英文:
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
答案1
得分: 0
"我已经自己解决了这个问题。导致上述错误的重大变更是在解析服务器版本4.10.14中引入的。在同一个版本中,已经集成了诸如邮箱地址是否已被使用以及输入的邮箱地址是否有效等检查。因此,我从我的云代码中移除了这两个检查。我唯一还检查的是是否提供了邮箱地址。我是这样做的:
if (!request.object.has("email")) {
throw new Parse.Error(1234, "无法注册用户,没有提供邮箱地址");
}
因此,不再需要读取邮箱地址了。"
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论