title: Authentication Service object is lost page on refresh in angularjs
body: <p>I'm using the mean.js boilerplate, which has authentication built in. However, I'm having a problem using the boilerplate Authentication Serivce. </p>
  
  <p>Here is the service:</p>
  
  <pre><code>'use strict';
  
  // Authentication service for user variables
  angular.module('users').factory('Authentication', [
  
  
      function() {
          var _this = this;
          var _user_exists = {};
  
          _this._data = {
              user: window.user
          };
          return _this;
      }
  ]);
  </code></pre>
  
  <p>Now in the Authentication controllers when I sign in I have the following snippet:</p>
  
  <pre><code>$http.post('/auth/signin', $scope.credentials).success(function(response) {
                  // If successful we assign the response to the global user model
                  $scope.authentication.user = response;
  </code></pre>
  
  <p>Which is great - as there is now a user object within $scope.authentication that contains the user data. This then customises the  the header view that has the customised navbar (with user data from $scope.authentication.user). </p>
  
  <p>However, I'm using HTML5, and every time i refresh the page it seems that the user object is overwritten and becomes empty - which seems as thought the user has been logged out (on the nav bar). </p>
  
  <p>However I can still see all of the user data if I do <code>'console.log($scope.authentication._data.user);'</code></p>
  
  <p>Any thoughts would be appreciated</p>