title: Correct way to use firebaseAuthClient and angularJS
body: <p>Been playing around with firebase and angularjs and just trying to put some little things together. I have the auth working now in a controller with this function called on the sign in button click:</p>
  
  <pre><code>$scope.signin = function(){
          var user1 = $scope.cred.user;
          var pass1 = $scope.cred.password;
  
          var ref = new Firebase("https://kingpinapp.firebaseio.com");
          var auth = new FirebaseAuthClient(ref, function(error, user) {
              if (user) {
                  // user authenticated with Firebase
                  console.log(user);
  
  
              } else if (error) {
                   // an error occurred authenticating the user
                   console.log(error);
  
                  } else {
                  // user is logged out
              }   
          });
          auth.login('password', {
              email: user1,
              password: pass1,
              rememberMe: false
          });
          console.log("tracer");
  }
  </code></pre>
  
  <p>Now this is great and works fine. But it seems to work in a async manner for example my console.log("tracer") returns before the user object of the auth.login. I know I probably need to work with promises to get this done and tried doing the following:</p>
  
  <pre><code>var defer = $q.defer();
  defer.auth
  .then(function() {
      auth.login('password', {
          email: user1,
          password: pass1,
          rememberMe: false
      });
  })
  .then(function() {
      console.log("tracer");
  })
  </code></pre>
  
  <p>But i'm receiving a $q is not defined after declaring it in the controller module. So what I'm trying to do is</p>
  
  <ol>
  <li>check if the user is logged in.</li>
  <li>wait till I receive a yes/no</li>
  <li>if not logged in. use auth.login</li>
  <li>else user user logged in do some other things</li>
  </ol>
  
  <p>I thought of putting the auth.login function in the else of the variable auth but that doesn't seem like it would work. Just trying to figure out the proper logic in understanding how to get this to work.</p>