I'm having some trouble authenticating with a factory in my app. The goal is to get a token only if the user has not already been authenticated. When I use the code below, I get the following error:
Cannot read property 'uid' of null
I can't tell if this is just a minor syntax issue or something bigger. It looks like none of the code starting with var authData is being read. 
(function() {
  'use strict';
   angular.module('firebase.auth', ['firebase', 'firebase.ref'])
   .factory('Auth', ['$firebaseAuth', 'Ref', function ($firebaseAuth, Ref) {
        return $firebaseAuth(Ref);
        var authData = Ref.getAuth();
        console.log(authData);
         if (authData) {
            console.log('already logged in with ' + authData.uid);
          } else {
            return Auth.$authAnonymously({rememberMe: true}).then(showError);
             function showError(err) {
              Login.err = err;
            }
          }
        }
    ]);
})();
angular.module('App')
   .factory('Projects', function ($firebaseArray, fbURL, Auth, Ref) {
        var authData = Ref.getAuth();
        var ref = new Firebase(fbURL + '/projects/' + authData.uid);
          return $firebaseArray(ref);
})