简体   繁体   English

FIRAuth.auth()?. createUser不会创建用户

[英]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.

相关问题 无法使用 Firebase 身份验证:FIRAuth.auth 不起作用 - Cannot use Firebase authentication: FIRAuth.auth does not work Firebase-iOS Swift:FIRAuth.auth()。signOut()未注销当前用户 - Firebase - iOS Swift: FIRAuth.auth().signOut() not signing out current user FIRAuth.auth()编译错误:“无法对非可选值'FIRAuth'使用可选链接” - FIRAuth.auth() compiling error: “Cannot use optional chaining on non optional value 'FIRAuth'” 使用FIRAuth.auth()?. signIn(withEmail进行登录后,GIDSignIn.sharedInstance()。hasAuthInKeychain()为null - After logging with FIRAuth.auth()?.signIn(withEmail , GIDSignIn.sharedInstance().hasAuthInKeychain() is null 使用FIRAuth实施创建用户时遇到问题 - Having problems implementing Create User with FIRAuth 'auth()'不可用:使用对象构造'FIRAuth()' - 'auth()' is unavailable : use object construction 'FIRAuth()' Firebase Auth 方法 createUser 未显示正确的参数 - Firebase Auth method createUser not showing right parameters iOS FIRAuth:有什么方法可以从用户uid获取用户电子邮件? - iOS FIRAuth : Is there any way to get user email from user uid? 无法在 Swift 3 中将 Facebook 用户属性传递给 Firebase FIRAuth - Unable to pass Facebook User properties to Firebase FIRAuth in Swift 3 Firebase Auth.auth().createUser 方法跳过 ios, swift - Firebase Auth.auth().createUser Method skipped ios, swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM