Advertisement
Guest User

Code-Example-Jett

a guest
Dec 13th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.40 KB | None | 0 0
  1.     @IBAction func signInTapped(_ sender: AnyObject) {
  2.        
  3.         if let email = emailField.text, let pwd = pwdField.text {
  4.             FIRAuth.auth()?.signIn(withEmail: email, password: pwd, completion: { (user, error) in
  5.                 if error == nil {
  6.                     print("JETT: Email user authenticated with Firebase")
  7.                     if let user = user {
  8.                         let userData = ["provider": user.providerID,
  9.                                         "uid": user.uid]
  10.                         self.completeSignIn(id: user.uid, userData: userData)
  11.                     }
  12.                 } else {
  13.                     FIRAuth.auth()?.createUser(withEmail: email, password: pwd, completion: { (user, error) in
  14.                         if error != nil {
  15.                             print("JETT: Unable to authenticate with Firebase using email")
  16.                         } else {
  17.                             print("JETT: Successfully Authenticated with Firebase")
  18.                             if let user = user {
  19.                                 let userData = ["provider": user.providerID,
  20.                                                 "uid": user.uid]
  21.                                 self.completeSignIn(id: user.uid, userData: userData)
  22.                             }
  23.                         }
  24.                     })
  25.                 }
  26.             })
  27.         }
  28.        
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement