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帮助吗?
- SPA和node.js服务器的身份validation
- 我如何使用node.js和PHP来请求谷歌浏览器中的客户端js的大查询authentication
- 何时生成ssl密钥和证书 – 出于安全原因
- Hello.js vs Passport.js?
- Firebase child.once在auth.signInWithEmailAndPasswordcallback中超时不一致
- 如何使用passport-google-oauth成功validation后redirect到原始页面
- NodeJS中的无状态身份validation库
- 在使用Passport-local作为validation策略的快速应用程序中,不受保护的端点
- 来自facebook的特定用户信息使用passport-facebook