MakeSchool-Tutorials / Makestagram-Swift-V3

14 stars 7 forks source link

12. Keeping Users Logged In #110

Open clankbear opened 5 years ago

clankbear commented 5 years ago

hi, I am wondering why need use Constants.UserDefaults.currentUser when we have Auth.auth().currentUser? thanks.

    if let _ = Auth.auth().currentUser,
       let userData = defaults.object(forKey: Constants.UserDefaults.currentUser) as? Data,
       let user = try? JSONDecoder().decode(User.self, from: userData) {
        User.setCurrent(user)
        initialViewController = UIStoryboard.initialViewController(for: .main)
    } else {
        initialViewController = UIStoryboard.initialViewController(for: .login)
    }