FirebaseUI-iOS icon indicating copy to clipboard operation
FirebaseUI-iOS copied to clipboard

Unable to create new user from email-password flow

Open kostapappas opened this issue 5 years ago • 15 comments

I'm using the following code

    authUI = FUIAuth.defaultAuthUI()
    authUI?.delegate = self
    authUI?.signIn(withProviderUI: FUIEmailAuth(), presenting: self, defaultValue: "")

but I when I add a new email I receive the message "That email address doesn't match an existing account. I cannot create a new user with that flow.

When I use the authUI?.authViewController with the same provider (FUIEmailAuth()) works fine (allows to create new users, even knows if a user is logged with another social media flow).

I think this is a bug.

Or I need to add something in my code?

My pods are the following Installing FBSDKCoreKit (4.44.1) Installing FBSDKLoginKit (4.44.1) Installing Firebase (5.20.2) Installing FirebaseAnalytics (5.8.1) Installing FirebaseAuth (5.4.2) Installing FirebaseAuthInterop (1.0.0) Installing FirebaseCore (5.4.1) Installing FirebaseDatabase (5.1.1) Installing FirebaseFirestore (1.2.1) Installing FirebaseInstanceID (3.8.1) Installing FirebaseStorage (3.1.1) Installing FirebaseUI (6.2.1)

kostapappas avatar May 01 '19 09:05 kostapappas

@kostapappas can you share a project that reproduces this issue, or are you able to reproduce this issue with the sample project?

morganchen12 avatar Jun 18 '19 20:06 morganchen12

Did you find a solution for that issue? I'm also trying to use FirebaseUI for sign up / create account, but didn't find a way to do that with FirebaseUI... Thanks

shahartap avatar Aug 14 '19 12:08 shahartap

@morganchen12 I'm also facing this issue.

Here is my code:

func presentLoginUI(from vc: UIViewController) {
  guard let authUi = FUIAuth.defaultAuthUI() else { return }
  authUi.tosurl = URL(string: Constants.Legal.tosUrl)
  authUi.delegate = self
  if #available(iOS 13, *) {
    authUi.isInteractiveDismissEnabled = false
  }
  
  let emailAuth = FUIEmailAuth(authAuthUI: authUi, signInMethod: "password", forceSameDevice: true, allowNewEmailAccounts: true, actionCodeSetting: ActionCodeSettings())
  emailAuth.signIn(withPresenting: vc, email: nil)
}

Please note allowNewEmailAccounts param is set to true. This is a real issue that should be addressed asap.

Can you you please check it out?

borut-t avatar Nov 04 '19 08:11 borut-t

@morganchen12 can you prioritize this issue since users are unable to create an account.

borut-t avatar Nov 05 '19 08:11 borut-t

@morganchen12 and please change the label from question to bug.

borut-t avatar Nov 05 '19 08:11 borut-t

I'll take care of it this week.

morganchen12 avatar Nov 05 '19 16:11 morganchen12

Can you share a sample that reproduces this issue?

morganchen12 avatar Nov 05 '19 16:11 morganchen12

@morganchen12 take a look at the code above ☝️.

borut-t avatar Nov 05 '19 19:11 borut-t

I'm unable to reproduce this issue running the same code in the sample. Can you set a symbolic breakpoint for -[FUIAuthBaseViewController showAlertWithMessage:] and specify the parameter for the appropriate localized value of kStr_UserNotFoundError, and then share the resulting stack trace?

The only place that dialogue is raised directly is here, all other appearances of this dialogue are a result of backend responses with error code FIRAuthErrorCodeUserNotFound.

morganchen12 avatar Nov 05 '19 20:11 morganchen12

Here is the stack:

<_NSCallStackArray 0x6000004acd50>(
0   ???                                 0x000000014b8481e7 0x0 + 5561942503,
1   myApp12-ios DEV                     0x0000000105fb14e0 main + 0,
2   myApp12-ios DEV                     0x0000000106a76371 __38-[FUIEmailEntryViewController onNext:]_block_invoke + 2753,
3   myApp12-ios DEV                     0x000000010640af9f __49-[FIRAuth fetchSignInMethodsForEmail:completion:]_block_invoke_3 + 111,
4   libdispatch.dylib                   0x0000000114cc8df8 _dispatch_call_block_and_release + 12,
5   libdispatch.dylib                   0x0000000114cc9d6c _dispatch_client_callout + 8,
6   libdispatch.dylib                   0x0000000114cd7e24 _dispatch_main_queue_callback_4CF + 1500,
7   CoreFoundation                      0x0000000113b08e49 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9,
8   CoreFoundation                      0x0000000113b03aa9 __CFRunLoopRun + 2329,
9   CoreFoundation                      0x0000000113b02e66 CFRunLoopRunSpecific + 438,
10  GraphicsServices                    0x00000001165b7bb0 GSEventRunModal + 65,
11  UIKitCore                           0x000000012297bdd0 UIApplicationMain + 1621,
12  myApp12-ios DEV                     0x0000000105fb152b main + 75,
13  libdyld.dylib                       0x0000000114d51d29 start + 1
)

The resulting error message is: That email address doesn’t match an existing account.

100% reproducible.

borut-t avatar Nov 06 '19 11:11 borut-t

@morganchen12 can you prioritize this bug? We are kinda blocked on this. We'll need to revert the version if this doesn't get fixed soon.

borut-t avatar Nov 08 '19 08:11 borut-t

Looks like your code is somehow hitting the codepath I mentioned in my previous comment despite setting allowNewEmailAccounts to true. I'm still unable to reproduce this issue using the code snippet you provided and the auth sample in the samples/swift folder of this repository.

Are you able to reproduce this issue if pulling FirebaseUI from master? Can you share a compilable sample that reproduces this issue?

morganchen12 avatar Nov 11 '19 21:11 morganchen12

@morganchen12 I've downloaded repo from the master branch, added a new row Email Login Sample which triggers UI the same way as I do it in our app. And with no surprise, the issue is the same. I've attached a video and project in the zip file.

Please review the project. Look at the presentLoginUI(from vc: UIViewController) method inside SamplesViewController.

If you need more help, lmk. Otherwise, I expect a bugfix release asap.

Thanks 🙌

borut-t avatar Nov 12 '19 08:11 borut-t

Looks like this is an error in our architecture that's unlikely to be easily fixed by a patch, but fortunately the workaround is very simple.

What's happening is allowNewEmailAccounts is implicitly nil because the FUIAuth.providers property has not been set. The FUIAuth callback responsible for completing the sign in flow needs to fetch state from that provider, so if you don't associate it with the FUIAuth instance you'll get this error.

You can fix it by adding this line before launching the sign in flow.

func presentLoginUI(from vc: UIViewController) {
  guard let authUi = FUIAuth.defaultAuthUI() else { return }
  authUi.tosurl = URL(string: Constants.Legal.tosUrl)
  authUi.delegate = self
  if #available(iOS 13, *) {
    authUi.isInteractiveDismissEnabled = false
  }
  
  let emailAuth = FUIEmailAuth(authAuthUI: authUi, signInMethod: "password", forceSameDevice: true, allowNewEmailAccounts: true, actionCodeSetting: ActionCodeSettings())
+ FUIAuth.defaultAuthUI()!.providers = [emailAuth]
  emailAuth.signIn(withPresenting: vc, email: nil)
}

I'll look at making the error more explicit in a minor release.

morganchen12 avatar Nov 12 '19 18:11 morganchen12

Thanks @morganchen12, it works 🙌

borut-t avatar Nov 13 '19 08:11 borut-t