//Just a struct to save information about the User
var user = AppUser()
override func viewDidLoad() {
super.viewDidLoad()
//Verify if user is logged in
verifyUser()
user.email = "blabla"
print("viewdidload user: \(user)")
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
print("viewdidappear user: \(user)")
}
func verifyUser() {
print("verify user called")
//Log in verification
guard let userID = Auth.auth().currentUser?.uid else {
perform(#selector(handleLogOut), with: nil, afterDelay: 0)
print("nil user")
return
}
ref.child("users").child(userID).observeSingleEvent(of: .value, with: { (snapshot) in
if let dictionary = snapshot.value as? [String: AnyObject] {
self.user = AppUser(dictionary: dictionary)
print(self.user)
}
}) { (error) in
print(error.localizedDescription)
}
}
//Just a struct to save information about the U