title: Angular refresh kills user session
body: <p>I have a problem with my angular app- after a user signs in, if he hits the refresh button, the signin info is lost and the app redirects to the log in page. I found a SO answer for something similar  <a href="https://stackoverflow.com/questions/17408475/how-to-keep-login-status-after-refresh-using-angular-js">here using $cookieStore</a> but I don't think it can work for me as I'm not using cookies. Can anyone suggest a solution? Here's my authorization service-</p>
  
  <pre><code>var app = angular.module('myApp.services');
  
  app.factory('SignIn', ['$resource', '$q', function($resource, $q) {
      var signInUrl = 'https://example.com'
      var API = $resource(signInUrl, {}, {
          signIn: {
              withCredentials: true,
              url: signInUrl + '/session',
              method: 'POST'
          },
          signOut: {
              url: authApiUrl + '/session',
              method: 'DELETE'
          },
          currentUser: {
              url: signInUrl + '/users/@me',
              method: 'GET'
          }
      });
  
  
      var _currentUser = undefined;
  
      return {
          isAuthenticated: function() {
              return !!_currentUser;
          },
          getUser: function(){
              var d = $q.defer();
  
              // If _currentUser is undefined then we should get current user
              if (_currentUser === undefined) {
                  API.currentUser(function(userData) {
                      _currentUser = userData;
                      d.resolve(userData);
                  }, function(response) {
                      if (response.statusCode === 401) {
                          _currentUser = null;
                          d.resolve(_currentUser);
                      } else {
                          d.reject(response);
                      }
                  });
              } else {
                  d.resolve(_currentUser);
              }
  
              return d.promise;
          },
          signIn: function(username, password){
              var d = $q.defer();
  
              API.signIn({email: username, password: password}, function(data, headers){
                  _currentUser = data;
                  d.resolve(_currentUser);
              }, d.reject);
  
              return d.promise;
          },
          signOut: function(){
              var d = $q.defer();
  
              API.signOut(function(){
                  _currentUser = null;
                  d.resolve();
              }, d.reject);
  
              return d.promise;
          }
      };
  }]);
  </code></pre>