Hello.
I am trying to do some passport authentication with AngularJS 1.6 and Node.
I have all my code in place and most of it works apart from checking if a 
user is authenticated before allowing them to a certain page.  I have a 
promise which should be resolved but it just hangs

.when('/profile', {
      templateUrl: 'views/profile.html',
      resolve: {
        logincheck: checkLoggedin
      }
    })
    .otherwise({
      redirectTo: '/home'
    })
});

var checkLoggedin = function($q, $timeout, $http, $location, $rootScope) {
  var deferred = $q.defer();

  $http.get('/loggedin').success(function(user) {
    $rootScope.errorMessage = null;
    //User is Authenticated
    if (user != '0') {
      $rootScope.currentUser = user;
      deferred.resolve();
    } else { //User is not Authenticated
      $rootScope.errorMessage = 'You need to log in.';
      deferred.reject();
      $location.url('/home');
    }
  });
  return deferred.promise;
}

Once the user POSTs to /login with their creds they get a 304 to /loggedin 
but it doesnt then redirect to /profile (or /home) it just sits there.

Can anyone see where I have gone wrong in this code?

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to