Ionic and Firebase auto login
<p>Since firebase did their major update, it has been nearly impossible for me to find answers to basic questions. Even using their docs.</p>

<p>My question is how do I allow my users to sign in once on my app and stay logged in indefinitely or for a set amount of time? </p>

<p>Once I have a user logged in, how can I access their data? Like first and last name? Do I have to create a database and link to the userID somehow?</p>

<p>I am also struggling to understand how "firebase.auth().signInWithEmailAndPassword(email, password)" works since I am not providing it my firebase url. is it pulling it from the config obj on the index page?</p>

<p>Here is my angular code:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>appControllers.controller('userCtrl', ['$scope', '$rootScope', '$ionicPlatform', '$cordovaDevice', '$mdToast', '$mdBottomSheet', '$timeout', '$stateParams', '$state', 'LogIn', 'SignUp', '$http', '$firebaseAuth',
  function($scope, $rootScope, $ionicPlatform, $cordovaDevice, $mdToast, $mdBottomSheet, $timeout, $stateParams, $state, LogIn, SignUp, $http, $firebaseAuth) {
    var devid;
    $scope.id = "1";
    $scope.errorMsg = "";

    // timeout to get device ID
    $timeout(function() {
      document.addEventListener("deviceready", onDeviceReady, false);

      function onDeviceReady() {
        console.log(device.cordova);
        $scope.id = $cordovaDevice.getUUID();
        return $scope.id;
      }


    }, 1000);

    // watches change in DEVID
    $scope.updateID = function() {
      devid = $scope.id;
      console.log(devid);
      return devid;
    };

    $scope.initialForm = function() {
      $scope.moveBox = function() {
          // $("#signupbox").fadeOut();
          $('#signupbox').animate({
            'marginTop': "+=170px" //moves down
          });

          $timeout(function() {
            $state.go('app.signup');
          }, 500);

          $timeout(function() {
            $('#signupbox').animate({
              'marginTop': "-=170px" //moves down
            });
          }, 1000);
        } // end animate

      // Toast for empty Fields
      $scope.showAlert = function(menuName, time) {
          //Calling $mdToast.show to show toast.
          $mdToast.show({
            controller: 'toastController',
            templateUrl: 'toast.html',
            hideDelay: time,
            position: 'top',
            locals: {
              displayOption: {
                title: menuName
              }
            }
          });
        } // End showToast.

      // check LogIn
      var em, pw;
      $scope.user = {};
      $scope.updateEmail = function() {
        em = $scope.user.email;
        console.log(em);
        return em;
      };
      $scope.updatePass = function() {
        pw = $scope.user.pass;
        console.log(pw);
        return pw;
      };

      // Password Validation
      $scope.validatePass = function(ppw) {
        if (ppw.length &lt; 8) {
          $scope.errorMsg = "Password must be at least 8 characters long";
        }
      };

      // start login
      $scope.logInNow = function() {
        var sdata = {
          em: em,
          pw: pw
        };

        if (pw == "" || pw == null) {
          $scope.errorSignIn = "Fields cannot be blank";
        }
        // FIREBASE LOGIN
        else {
          firebase.auth().signInWithEmailAndPassword(sdata.em, sdata.pw)
            .then(function(authData) {
              console.log("Logged in as:", authData.uid);
              $state.go('app.types');
            }).catch(function(error) {
              console.error("Authentication failed:", error);
              $scope.errorSignIn = "Email or Password is invalid";
            });
        }
      }



    };

    $scope.initialForm();




  }
]);</code></pre>
</div>
</div>
</p>