Guest User

Untitled

a guest
Oct 8th, 2018
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. static func signUp(username: String, email: String, password: String, firstname: String, lastname: String, imageData: Data, onSuccess: @escaping () -> Void, onError: @escaping (_ errorMessage: String?) -> Void) {
  2. Auth.auth().createUser(withEmail: email, password: password) { (authData: AuthDataResult?, error: Error?) in
  3. if error != nil {
  4. onError(error?.localizedDescription)
  5. return
  6. }
  7. let uid = authData!.user.uid
  8. let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF).child("profile_image").child(uid)
  9.  
  10. storageRef.putData(imageData, metadata: nil, completion: { (_, error: Error?) in
  11. if error != nil {
  12. return
  13. }
  14. storageRef.downloadURL(completion: { (url: URL?, error: Error?) in
  15. if let profileImageUrl = url?.absoluteString {
  16.  
  17. self.setUserInformation(profileImageUrl: profileImageUrl!, username: username, email: email, firstname: firstname, lastname: lastname, uid: uid, onSuccess: onSuccess)
  18. }
  19.  
  20. }
  21.  
  22. )}
  23.  
  24. )}
  25. }
Add Comment
Please, Sign In to add comment