[英]FIRAuth.auth()?.createUser does not create user
I've already found the answer to this problem, I am posting this here since I was unable to find the answer on here. 我已经找到了这个问题的答案,我在这里发帖,因为我在这里找不到答案。
The problem is that FIRAuth.auth()?.createUser
does not throw an error, but the user is also not created. 问题是
FIRAuth.auth()?.createUser
不会抛出错误,但也不会创建用户。 Which shouldn't even be possible since the Firebase docs say if there is no error in the completion handler then the account creation was successful. 哪个甚至不可能,因为Firebase文档说完成处理程序中没有错误,那么帐户创建成功。
The documentation states that any password validation needs to be done by the app before calling FIRAuth.auth()?.createUser
, but doesn't say that there are any requirements set by Firebase. 该文档指出,在调用
FIRAuth.auth()?.createUser
之前,应用程序需要完成任何密码验证,但并未说明Firebase设置了任何要求。
So by all sources of available information, if the completion handler doesn't pass an error, the account must be there, but it is possible to get no error and also not have the account created. 因此,通过所有可用信息源,如果完成处理程序未传递错误,则该帐户必须在那里,但是可能没有错误并且也没有创建帐户。
When creating a user, be sure to handle errors. 创建用户时,请务必处理错误。
For example: 例如:
app.auth()
.createUserWithEmailAndPassword("tooshort@firebaseui.com", "fire")
.catch(function(error) {
console.error(error);
});
Shows the follow error in the JavaScript console: 在JavaScript控制台中显示以下错误:
{code: "auth/weak-password", message: "Password should be at least 6 characters"}
In swift you can get the same output by implementing a completion block. 在swift中,您可以通过实现完成块来获得相同的输出。 See the reference documentation , which also contains the error code you'll be getting
FIRAuthErrorCodeWeakPassword
. 请参阅参考文档 ,其中还包含您将获得
FIRAuthErrorCodeWeakPassword
的错误代码。
The documentation is incomplete. 文档不完整。 If you attempt to create an account with a password less than 6 characters it fails.
如果您尝试创建密码少于6个字符的帐户,则会失败。
If you try to create the account in the online console for your Firebase app, it will fail and give you an error message stating such. 如果您尝试在Firebase应用的在线控制台中创建帐户,它将失败并向您显示一条错误消息,说明此类情况。 But if you try to do it from within the app, it can silently fail.
但是如果你尝试在应用程序中执行它,它可以默默地失败。 The documentation says an error can be thrown for this issue, but it apparently won't always happen since I never got that error.
文档说这个问题可能会引发错误,但显然不会总是发生,因为我从来没有遇到过这个错误。
So to avoid this, check your password strings since they need to be at least 6 characters for it to succeed on Google's end. 因此,要避免这种情况,请检查您的密码字符串,因为它们需要至少6个字符才能在Google端成功。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.