Last active
July 14, 2017 09:53
-
-
Save PaulRBerg/b3d6fc31b439a67661d8eb86acdcf4f1 to your computer and use it in GitHub Desktop.
AdPacer - APLoginNetwork
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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