Skip to content

Instantly share code, notes, and snippets.

@PaulRBerg
Last active July 14, 2017 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulRBerg/b3d6fc31b439a67661d8eb86acdcf4f1 to your computer and use it in GitHub Desktop.
Save PaulRBerg/b3d6fc31b439a67661d8eb86acdcf4f1 to your computer and use it in GitHub Desktop.
AdPacer - APLoginNetwork
import UIKit
import FirebaseAuth
import MBProgressHUD
extension APLoginViewController {
/**
* Simply logins the user using the classic email & password.
*/
func login() {
MBProgressHUD.showAdded(to: self.view, animated: true)
FIRAuth.auth()?.signIn(withEmail: emailTextField.text!,
password: passwordTextField.text!,
completion: { [unowned self] (user, error) in
self.handleResponse(error: error)
})
}
/**
* Handles the response of the request made above. We're going to the playground.
*/
fileprivate func handleResponse(error: Error?) {
MBProgressHUD.hide(for: self.view, animated: true)
if error != nil {
APError.credential(error!)
return
}
/**
* The user is not successfully logged in until the email is verified.
*/
if !FIRAuth.auth()!.currentUser!.isEmailVerified {
APIntent.gotoEmailVerification(sender: self)
return
}
APIntent.gotoPlayground(sender: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment