Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private func saveUserInfo(firstLastName: String, user: User!, location: String, biography: String, password: String, phoneNumber: String){
- let locationRef = Global.refString
- let userInfo = ["firstLastName": firstLastName, "email": user.email!, "password": password, "location": location, "phoneNumber": phoneNumber, "biography": biography, "uid": user.uid, "photoURL": String(describing: user.photoURL!)] as [String : Any]
- let userRef = dataBaseRef.child(locationRef!).child(user.uid)
- userRef.setValue(userInfo) { (error, ref) in
- if error == nil{
- print("USER SAVED")
- self.logIn(email: user.email!, password: password)
- }else{
- print(error?.localizedDescription)
- }
- }
- }
- func loadUserInfo(){
- let locationRef = Global.refString
- let userRef = dataBaseRef.child(locationRef!).child(Auth.auth().currentUser!.uid)
- userRef.observe(.value, with: { (snapshot) in
- let user = Users(snapshot: snapshot)
- if let username = user.name{
- self.nameLabel.text = username
- }
- if let number = user.phoneNumber{
- self.phone = Int(number)
- }
- if let userLocation = user.location{
- self.bioLabel.text = userLocation
- }
- self.storageRef.storage.reference(forURL: imageOld).getData(maxSize: 10 * 1024 * 1024, completion: { (imgData, error) in
- if error == nil {
- DispatchQueue.main.async {
- if let data = imgData {
- self.avatar.image = UIImage(data: data)
- }
- }
- }else {
- print(error!.localizedDescription)
- }
- }
- )}
- }) { (error) in
- print(error.localizedDescription)
- }
- }
- }
- struct Global
- {
- static var Location : String!
- static var usersListSent
- = [String]()
- static var refString: String!
- }
Add Comment
Please, Sign In to add comment