Added a basic login system
diff --git a/views/ngXosViews/subscriberPortal/src/app/fw/mast/mast.js b/views/ngXosViews/subscriberPortal/src/app/fw/mast/mast.js
index 090cb59..9b27628 100644
--- a/views/ngXosViews/subscriberPortal/src/app/fw/mast/mast.js
+++ b/views/ngXosViews/subscriberPortal/src/app/fw/mast/mast.js
@@ -15,32 +15,23 @@
  */
 
 (function () {
-    'use strict';
+  'use strict';
 
-    var urlSuffix = '/rs/logout';
+  var urlSuffix = '/rs/logout';
 
-    angular.module('cordMast', [])
-        .controller('CordMastCtrl',
-        ['$log','$scope', '$resource', '$location', '$window',
-            function ($log, $scope, $resource, $location, $window) {
-                var LogoutData, resource;
-
-                $scope.logout = function () {
-                    $log.debug('Logging out...');
-                    LogoutData = $resource($scope.shared.url + urlSuffix);
-                    resource = LogoutData.get({},
-                        function () {
-                            $location.path('/login');
-                            $window.location.href = $location.absUrl();
-                            $log.debug('Resource received:', resource);
-                        });
-                };
-            }])
-
-        .directive('mast', function () {
-            return {
-                restrict: 'E',
-                templateUrl: 'app/fw/mast/mast.html'
-            };
+  angular.module('cordMast', [])
+    .controller('CordMastCtrl', function ($log, $scope, $location, User) {
+      $scope.logout = function () {
+        User.logout()
+        .then(function(){
+          $location.path('/login');
         });
+      };
+    })
+    .directive('mast', function () {
+      return {
+        restrict: 'E',
+        templateUrl: 'app/fw/mast/mast.html'
+      };
+    });
 }());
diff --git a/views/ngXosViews/subscriberPortal/src/app/fw/services/rest.js b/views/ngXosViews/subscriberPortal/src/app/fw/services/rest.js
index 2bb2b82..9e6596e 100644
--- a/views/ngXosViews/subscriberPortal/src/app/fw/services/rest.js
+++ b/views/ngXosViews/subscriberPortal/src/app/fw/services/rest.js
@@ -1,13 +1,14 @@
 "use strict";
 
 angular.module('cordRest', [])
-  .service('User', function($http, $q, cordConfig){
+  .service('User', function($http, $q, $cookies, cordConfig){
     this.login = function(username, password){
       var deferred = $q.defer();
 
       $http.post(cordConfig.url + '/xoslib/login/', {username: username, password: password})
       .then(function(res){
-          deferred.resolve(JSON.parse(res.data.user));
+        $cookies.put('user', res.data.user);
+        deferred.resolve(JSON.parse(res.data.user));
       })
       .catch(function(e){
         throw new Error(e);
@@ -15,6 +16,21 @@
 
       return deferred.promise;
     };
+
+    this.isLoggedIn = function(){
+      var user = $cookies.get('user');
+      if( angular.isDefined(user)){
+        return true;
+      }
+      return false;
+    };
+
+    this.logout = function(){
+      var deferred = $q.defer();
+      $cookies.remove('user');
+      deferred.resolve();
+      return deferred.promise;
+    };
   })
   .service('Subscribers', function($resource, cordConfig){
     return $resource(cordConfig.url + '/xoslib/rs/subscriber');
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/login/login.js b/views/ngXosViews/subscriberPortal/src/app/view/login/login.js
index 1d50b20..8a3f2cf 100644
--- a/views/ngXosViews/subscriberPortal/src/app/view/login/login.js
+++ b/views/ngXosViews/subscriberPortal/src/app/view/login/login.js
@@ -40,7 +40,6 @@
 
             User.login($scope.email, $scope.password)
             .then(function(user){
-              console.log(user);
               $location.url('/home');
             });
 
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/user/user.js b/views/ngXosViews/subscriberPortal/src/app/view/user/user.js
index ecdf970..f7450cb 100644
--- a/views/ngXosViews/subscriberPortal/src/app/view/user/user.js
+++ b/views/ngXosViews/subscriberPortal/src/app/view/user/user.js
@@ -75,7 +75,6 @@
           });
 
         $scope.updateLevel = function(user){
-          console.log(user);
           user.$save()
             .then(function(){
               console.log('saved');
diff --git a/views/ngXosViews/subscriberPortal/src/cord.js b/views/ngXosViews/subscriberPortal/src/cord.js
index bae4b2e..f646be0 100644
--- a/views/ngXosViews/subscriberPortal/src/cord.js
+++ b/views/ngXosViews/subscriberPortal/src/cord.js
@@ -21,6 +21,7 @@
       'ngRoute',
       'ngResource',
       'ngAnimate',
+      'ngCookies',
       'cordRest',
       'cordMast',
       'cordFoot',
@@ -119,7 +120,14 @@
         }
       ]
     })
-    .run(function($location, cordConfig){
+    .run(function($rootScope, $location, cordConfig, User){
       cordConfig.url = 'http://' + $location.host() + ':' + $location.port();
+
+      // basic authentication
+      $rootScope.$on('$routeChangeStart', function(next, current) {
+        if(!User.isLoggedIn()){
+          $location.path('/login');
+        }
+      });
     });
 }());
diff --git a/views/ngXosViews/subscriberPortal/src/index.html b/views/ngXosViews/subscriberPortal/src/index.html
index 1d2e1e1..b00e425 100644
--- a/views/ngXosViews/subscriberPortal/src/index.html
+++ b/views/ngXosViews/subscriberPortal/src/index.html
@@ -26,6 +26,7 @@
     <script src="bower_components/angular-route/angular-route.js"></script>
     <script src="bower_components/angular-animate/angular-animate.js"></script>
     <script src="bower_components/angular-resource/angular-resource.js"></script>
+    <script src="bower_components/angular-cookies/angular-cookies.js"></script>
     <script src="bower_components/jquery/dist/jquery.js"></script>
 
     <script src="cord.js"></script>