var app = angular.module("estimator", ["firebase"]);


app.config(['$locationProvider', '$routeProvider',
  function($locationProvider, $routeProvider) {

    $routeProvider.
      when('/projects', {
        templateUrl: 'views/projects/index.html',
        controller: 'ProjectShowController',
        authRequired: 'true'
      }).
      when('/projects/:projectId', {
        templateUrl: 'views/projects/show.html',
        controller: 'ProjectChannelController',
        authRequired: 'true'
      }).
      otherwise({
        redirectTo: ''
      });
  }]);

app.controller('AuthController', ['$scope','$location','angularFireAuth',function($scope, $location,angularFireAuth){
    var url = "https://320ny.firebaseio.com/";
    var firebase = new Firebase(url);
    $scope.login_form= {};
    angularFireAuth.initialize(firebase, {
      scope: $scope, name: "user",
      callback: function(err, user) {
      }
    });

    $scope.login = function() {
      var email = $scope.login_form.email;
      var password = $scope.login_form.password;
     angularFireAuth.login('password',{
      email: email,
      password: password 
     });
    };
    $scope.logout = function() {
      angularFireAuth.logout();
    };

    $scope.$on("angularFireAuth:login", function(evt, user) {
      $location.path("/projects");
    });
    $scope.$on("angularFireAuth:logout", function(evt) {
      $location.path("#");
    });
    $scope.$on("angularFireAuth:error", function(evt, err) {
      console.log(err);
    });

}]);

app.controller('ProjectShowController', ['$scope', 'angularFire', function($scope){
  var url = "https://320ny.firebaseio.com/"
  var firebase = new Firebase(url);
}]);
@@ -616,16 +616,30 @@
 ation','
+angularFire','
 angularF
@@ -674,16 +674,30 @@
 ocation,
+ angularFire, 
 angularF
@@ -710,24 +710,29 @@
 h)%7B%0A    var 
+base_
 url = %22https
@@ -790,20 +790,44 @@
 irebase(
-url)
+base_url);%0A    $scope.myUser
 ;%0A    $s
@@ -847,16 +847,17 @@
 rm= %7B%7D;%0A
+%0A
     angu
@@ -912,16 +912,23 @@
 $scope, 
+%0A      
 name: %22u
@@ -943,55 +943,56 @@
     
-callback: function(err, user) %7B%0A      %7D%0A    %7D);
+path: %22#%22,%0A    %7D);%0A%0A    //authentication actions
 %0A%0A  
@@ -1114,24 +1114,25 @@
 sword;%0A     
+ 
 angularFireA
@@ -1154,16 +1154,18 @@
 word',%7B%0A
+  
       em
@@ -1182,16 +1182,18 @@
 ,%0A      
+  
 password
@@ -1204,16 +1204,17 @@
 ssword %0A
+ 
      %7D);
@@ -1290,24 +1290,55 @@
 ();%0A    %7D;%0A%0A
+%0A    // authentication events%0A%0A
     $scope.$
@@ -1383,24 +1383,213 @@
 vt, user) %7B%0A
+        var user_url = base_url+%22users/%22+user.id;%0A        var user_firebase = new Firebase(user_url);%0A        angularFire(user_firebase, $scope, %22myUser%22);%0A        $scope.myUser = user;%0A%0A  
       $locat
@@ -1611,32 +1611,33 @@
 ects%22);%0A    %7D);%0A
+%0A
     $scope.$on(%22

create a user instance via id in firebase on login