title: Current Firebase User Returning Nil
body: <p>I have an app using FirebaseAuth to authenticate users. I do this in an AuthService class;</p>
  <pre><code>import Foundation
  import FirebaseAuth
  class AuthService: NSObject {
      
      private override init() {}
      
      static let shared = AuthService()
      
      let currentUser = Auth.auth().currentUser
      var uid = Auth.auth().currentUser?.uid
  
      func checkAuthState(completion: @escaping(FirebaseAuth.User?) -&gt; Void) {
  //        let listener = Auth.auth().addStateDidChangeListener { (auth, user) in
          Auth.auth().addStateDidChangeListener { (auth, user) in
              switch user {
              case .none:
                  print(&quot;USER NOT FOUND IN CHECK AUTH STATE&quot;)
                  completion(nil)
              case .some(let user):
                  print(&quot;USER FOUND WITH ID: \(user.uid)&quot;)
                  completion(user)
              }
          }
  //        Auth.auth().removeStateDidChangeListener(listener)
      }
  }
  </code></pre>
  <p>I then sign in a user anonymously using checkAuthState function above. Once this operation completes with some user I perform an action to switch the <code>rootViewController</code>.</p>
  <pre><code>func checkAuthState() {
          authService.checkAuthState { (user) in
              switch user {
              case .none:
                  SceneDelegate.shared.rootController.showWelcomeController()
              case .some(_):
                  SceneDelegate.shared.rootController.showTabBarController()
              }
          }
      }
  }
  </code></pre>
  <p>Here is my code within my <code>RootViewController</code>;</p>
  <pre><code>func showWelcomeController() {
          let welcomeController = WelcomeController(authService: AuthService.shared)
          let navigationController = UINavigationController(rootViewController: welcomeController)
          addChild(navigationController)
          navigationController.view.frame = view.frame
          view.addSubview(navigationController.view)
          navigationController.didMove(toParent: self)
          currentController.willMove(toParent: nil)
          currentController.view.removeFromSuperview()
          currentController.removeFromParent()
          currentController = navigationController
      }
      
      func showTabBarController() {
          let tabBarController = TabBarController()
          addChild(tabBarController)
          tabBarController.view.frame = view.frame
          view.addSubview(tabBarController.view)
          tabBarController.didMove(toParent: self)
          currentController.willMove(toParent: nil)
          currentController.view.removeFromSuperview()
          currentController.removeFromParent()
          currentController = tabBarController
      }
  </code></pre>
  <p>The above operates all as expected and shows my <code>TabBarController</code>, however, I then run a function in one of my ViewControllers in my TabBarController which is;</p>
  <pre><code>var uid = Auth.auth().currentUser?.uid
  
  func readComments(query: Query, lastDocument: DocumentSnapshot?, completion: @escaping(Result&lt;[CommentModel], NetworkError&gt;) -&gt; ()) {
          guard let uid = auth.uid else { return completion(.failure(.userNotFound)) }
  // Other code
  </code></pre>
  <p>}</p>
  <p>However, I get the .userNotFound error? as it returns nil? I'm confused as checkAuthState is returning a user?</p>