Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
@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.")
} 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