简体   繁体   English

错误解析SDK:无法使用空名称注册用户

[英]Error Parse SDK: Cannot sign up user with an empty name

I am trying to sign up users with the Parse SDK. 我正在尝试使用Parse SDK注册用户。 My keys are correct and I have used my own code as well as the "Signing Up" code straight from Parse Quickstart Tutorial and I keep getting this error message: 我的密钥是正确的,我已经使用自己的代码以及直接来自Parse Quickstart Tutorial的“Signing Up”代码,我不断收到此错误消息:

Cannot sign up user with an empty name. 无法使用空名称注册用户。

I have even hardcoded values into the signUp function, and printed the values (and typeof) out to the console for accuracy, but still not luck. 我甚至在signUp函数中都有硬编码值,并将值(和typeof)输出到控制台以保证准确性,但仍然没有运气。 Here's a snippet of the function I created, it's practically straight out of the tutorial. 这是我创建的函数的片段,它几乎直接来自教程。

var newUserEmail    = document.getElementById("new-user-email").value;
var newUserPassword = document.getElementById("new-user-password").value;
var user = new Parse.User();
user.set("email", newUserEmail);
user.set("password", newUserPassword);
user.set("name", "no name");
user.signUp(null, {
    success: function(user) {
        console.log("New user signed up successfully!");
    },
    error: function(user, error) {
        console.log("You messed up. Error: " + error.message);
    }
});

You should set the username : 你应该设置username

user.set("username", "my name");

From Parse Quickstart Tutorial that you mentioned: 从您提到的Parse快速入门教程

If a signup isn't successful, you should read the error object that is returned. 如果注册不成功,则应阅读返回的错误对象。 The most likely case is that the username or email has already been taken by another user. 最可能的情况是用户名或电子邮件已被其他用户使用。 You should clearly communicate this to your users, and ask them try a different username. 您应该清楚地将此信息传达给您的用户,并要求他们尝试使用其他用户名。

You are free to use an email address as the username. 您可以使用电子邮件地址作为用户名。 Simply ask your users to enter their email, but fill it in the username property — Parse.User will work as normal. 只需要求您的用户输入他们的电子邮件,但填写用户名属性 - Parse.User将正常工作。 We'll go over how this is handled in the reset password section. 我们将在重置密码部分讨论如何处理它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM