title: Firebase issuing out 2 different uid's -Swift iOS
body: <p>I have all my pods correctly installed. My app launches and then when I get to scenes that have to access Firebase I've noticed there's a crash. The reason seems to be that Firebase is issuing me 2 different uid's and the one in Auth doesn't match the one in the Database.</p>
  
  <p>When my app launches in AppDelegate I have code to get the current uid.</p>
  
  <pre><code>//This is in App Delegate
  let myUserID = FIRAuth.auth()?.currentUser?.uid
  
  print("App Delegate: UID is \(myUserID!)")
  //An example print is 'App Delegate: UID is Abcdefg12345'
  </code></pre>
  
  <p>Next a SignUp scene is presented and in that view controller I have</p>
  
  <pre><code>FIRAuth.auth()?.createUserWithEmail(self.emailTextField.text!, password: self.passwordTextField.text!, completion: {
  
              //You can access the newly issued uid from user via user!uid
              (user, err) in
  
  print("SignUp: UID is \(user!uid)\n")
  //An example print is 'SignUp: UID is Vwxyz67890'
  </code></pre>
  
  <p>When I access user!uid (from user) I get a totally different uid from what is originally in the AppDelegate.</p>
  
  <p>However the uid that I get from user in FIRAuth.auth()?.createUserWithEmail is what's current in Auth but is not recognized in FirebaseDatabase.</p>
  
  <p>The odd thing is the uid that is printed in AppDelegate is what's current in the FirebaseDatabase but is not recognized in Auth. If this uid is changed upon signing up then it should not be available in the Database</p>
  
  <p>I also have a logout scene and when I press the logout button I get the logout uid as the same one created in FIRAuth.auth()?.createUserWithEmail</p>
  
  <p>Any ideas why I have 2 different uid's? This seems to be my crash issues.</p>
  
  <p>AppDelegate</p>
  
  <pre><code>import UIKit
  import Firebase
  import FirebaseAuth
  import FirebaseDatabase
  import FirebaseStorage
  import GoogleMaps
  
  @UIApplicationMain
  class AppDelegate: UIResponder, UIApplicationDelegate {
  
      var window: UIWindow?
  
      override init() {
          super.init()
  
          //Configure App for FireBase
          FIRApp.configure()
  
          //Firebase App Offline Updates
          FIRDatabase.database().persistenceEnabled = true
  
          GMSServices.provideAPIKey("mykey")
      }//end override init
  
  
  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {
  
          let myUserID = FIRAuth.auth()?.currentUser?.uid
  
          let connectedRef = FIRDatabase.database().referenceWithPath(".info/connected")
          connectedRef.observeEventType(.Value, withBlock: { 
                      (connected) in
  
          if let boolean = connected.value as? Bool where boolean == true {
                  print("\nApp Delegate: Firebase is connected")
  
                  if myUserID != nil{
                  //This uid is different from the one created in signUp but yet it is what's shown in the Database but not Auth
                  print("App Delegate: UID is \(myUserID!)\n")
                  }
              } else {
                  print("\nApp Delegate: Firebase is NOT connected\n")
              }
          })
  
  self.window?.makeKeyAndVisible()
  
          return true
      }
  </code></pre>
  
  <p>SignUpController</p>
  
  <pre><code>import UIKit
  import Firebase
  import FirebaseAuth
  import FirebaseDatabase
  import FirebaseCrash
  
  class SignUpController: UIViewController {
  
  @IBOutlet weak var emailTextField: UITextField!
  @IBOutlet weak var passwordTextField: UITextField!
  
  var dbRef: FIRDatabaseReference!
  let myUserID = FIRAuth.auth()?.currentUser?.uid
  
  
  override func viewDidLoad() {
        super.viewDidLoad()
  self.dbRef = FIRDatabase.database().reference()
  }
  
  @IBAction func signUpButton(sender: UIButton) {
  
  FIRAuth.auth()?.createUserWithEmail(self.emailTextField.text!, password: self.passwordTextField.text!, completion: {
  
              (user, err) in
  
  //This uid is different from AppDelegate but is what is shown in Auth but not in Database
  print("\nSignUp: UID is \(user!uid)\n")
  print("Now Look at the UID printed from the above property myUserID: \(self.myUserID)")
  
  if err != nil{
          print((error?.localizedDescription)\n)
         }
  
  let usersRef = self.dbRef.child("users")
  let userIDRef = usersRef.child(self.myUserID!)
  let userEmailRef = userIDRef.child("userEmailRef")
  
  let email = self.self.emailTextField.text!
  let dict = [String:AnyObject]()
  dict.updateValue(email, forKey: "emailKey")
  dict.updateValue(self.myUserID!, forKey: "userIDKey")
  
  userEmailRef.updateChildValues(dict, withCompletionBlock: {
  
                  (error, user) in
  
                  if error != nil{
                      print(err?.localizedDescription\n")
                  }
       })
     })
   }
  }
  </code></pre>
  
  <p>LogoOutController</p>
  
  <pre><code>import UIKit
  import Firebase
  import FirebaseAuth
  import FirebaseDatabase
  import FirebaseCrash
  
  class LogoutController: UIViewController {
  
  var dbRef: FIRDatabaseReference!
  let myUserID = FIRAuth.auth()?.currentUser?.uid
  
  
  override func viewDidLoad() {
        super.viewDidLoad()
  self.dbRef = FIRDatabase.database().reference()
  }
  
  
  @IBAction func signUpButton(sender: UIButton) {
  
  try! FIRAuth.auth()!.signOut()
  
  print("\nLogout: UID is \(self.myUserID!)")
  
    }
  }
  </code></pre>