0

Since updating to Swift 3.0 even with the correct password I receive the incorrect message. Has anyone had this problem with authorizing users on Firebase?

@IBAction func LoginToAccount(_ sender: AnyObject) { if let email = emailLogin.text, let password = passwordLogin.text { FIRAuth.auth()?.signIn(withEmail: email, password: password, completion: { (user, error) in if error != nil{ print("Incorrect") let alert = UIAlertController(title: "Error", message: "Incorrect Email or Password.", preferredStyle: UIAlertControllerStyle.alert) let action = UIAlertAction(title: "Ok", style: .default, handler: nil) alert.addAction(action) self.present(alert, animated: true, completion: nil) }else{ if error == nil { self.performSegue(withIdentifier: "AdminSegue", sender: self) } } }) } } } 
4
  • What do you mean by not working? Commented Oct 12, 2016 at 13:24
  • it will be useful if you show us what the error message is. Commented Oct 12, 2016 at 13:35
  • What I mean is even with the correct password I am just getting the message string "Incorrect email or password". Worked fine before updating to Swift 3.0 Commented Oct 12, 2016 at 16:16
  • Okay so really strange. The login works fine on the device it just doesn't work in the simulator. This is only since updating to Xcode 8 Commented Oct 16, 2016 at 23:28

3 Answers 3

1

If you could create an email and have problem with sign in then it would be like my case. Just check your keychain accessibility from yourproject.xcodeproject -> Capabilities -> keychain Sharing - > On if it is off.

Sign up to request clarification or add additional context in comments.

Comments

1

After some research this is apparently an issue with Simulator 10.0 not allowing Firebase to write values to the keychain. Something they are working on apparently but it doesn't affect app on actual device.

Comments

0

You have to make sure the user has been created initially, because you have to create a user first and then sign in using the created user.

@IBAction func LoginToAccount(_ sender: AnyObject) { if let email = emailLogin.text, let password = passwordLogin.text { FIRAuth.auth()!.createUser(withEmail: email, password: password) { user, error in if error == nil { FIRAuth.auth()!.signIn(withEmail: email, password: password, , completion: { (user, error) in if error != nil{ print("Incorrect") let alert = UIAlertController(title: "Error", message: "Incorrect Email or Password.", preferredStyle: UIAlertControllerStyle.alert) let action = UIAlertAction(title: "Ok", style: .default, handler: nil) alert.addAction(action) self.present(alert, animated: true, completion: nil) } else { if error == nil { self.performSegue(withIdentifier: "AdminSegue", sender: self) } } }) } } } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.