Created
April 14, 2016 07:24
-
-
Save charleshkang/59c65570b56dcb7d6821f4ac771dbc37 to your computer and use it in GitHub Desktop.
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
@IBAction func signUpButtonTapped(sender: AnyObject) | |
{ | |
let username = usernameTextField.text | |
let email = emailTextField.text | |
let password = passwordTextField.text | |
if username != "" && email != "" && password != "" { | |
DataService.dataService.BASE_REF.createUser(email, password: password, withValueCompletionBlock: { error, result in | |
if error != nil {3 | |
self.signupErrorAlert("Oops!", message: "Having some trouble creating your account. Please try again.") | |
print(error) | |
} else { | |
DataService.dataService.BASE_REF.authUser(email, password: password, withCompletionBlock: { err, authData in | |
let user = ["provider": authData.provider!, "email": email!, "username": username!] | |
DataService.dataService.createNewAccount(authData.uid, user: user) | |
}) | |
NSUserDefaults.standardUserDefaults().setValue(result ["uid"], forKey: "uid") | |
self.performSegueWithIdentifier("NewUserLoggedIn", sender: nil) | |
} | |
}) | |
} else { | |
signupErrorAlert("Oops!", message: "Don't forget to enter your email, password, and a username.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment