Angular Node JWT令牌authentication和页面redirect

我正在从https://auth0.com/blog/2014/01/07/angularjs-authentication-with-cookies-vs-token/学习JWT令牌authentication。 我试图实现它。 它工作正常。在这里,authentication后控制返回到相同的页面。 我的问题是我们如何可以redirect到客户端控制器的新的HTML页面(限制资源,of course!)?

我曾尝试过一些类似的东西

$scope.submit = function () { $http.post("http://localhost:3000/authenticate?uname=" + $scope.username + "&pwd=" + $scope.password + "") .success(function (data, status, headers, config) { $window.sessionStorage.token = data.token;// Save jwt in the sessionStorage $scope.isAuthenticated = true; var encodedProfile = data.token.split('.')[1]; var profile = JSON.parse(url_base64_decode(encodedProfile)); console.log('encoded profile is ' + profile); window.location.href="api/admin.html"; }) .error(function (data, status, headers, config) { // Erase the token if the user fails to log in delete $window.sessionStorage.token; $scope.isAuthenticated = false; // Handle login errors here $scope.error = 'Error: Invalid user or password'; $scope.welcome = ''; }); }; 

页面redirect总是导致admin.html与“UnauthorizedError”这是抓住server.Any帮助吗?