Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Auth.auth().createUser(withEmail: usernameField.text!, password: passwordField.text!) { user, error in
- if error == nil {
- if let user = user {
- let name = "\(self.firstNameField.text!) \(self.surnameField.text!)"
- //update the currentUser displayName property in Auth.
- let changeRequest = Auth.auth().currentUser?.createProfileChangeRequest()
- changeRequest?.displayName = name
- changeRequest?.commitChanges() { (error) in }
- //update the people array with the new user
- Database.database().reference(withPath: "people/\(user.uid)").updateChildValues(
- ["profile_picture": user.photoURL?.absoluteString ?? "",
- "full_name": name,
- "_search_index": ["full_name": user.displayName?.lowercased(),
- "reversed_full_name": user.displayName?.components(separatedBy: " ").reversed().joined(separator: "")]])
- //lastly, sign this new user in.
- Auth.auth().signIn(withEmail: self.usernameField.text!, password: self.passwordField.text!, completion: { authresult, error in
- print("Sign in complete, authresult: \(String(describing:authresult)), error: \(String(describing:error))")
- })
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment