Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 在sails js中使用私有页面处理JWT令牌_Angularjs_Node.js_Sails.js_Jwt_Satellizer - Fatal编程技术网

Angularjs 在sails js中使用私有页面处理JWT令牌

Angularjs 在sails js中使用私有页面处理JWT令牌,angularjs,node.js,sails.js,jwt,satellizer,Angularjs,Node.js,Sails.js,Jwt,Satellizer,我想在我的系统中增加限制。然后我使用JWT令牌。然后我首选statellizer作为前端 一旦用户登录系统,它将生成如下令牌 EYJ0EXAIIOIJKV1QILJHBGCIOIJIUZI1NIJ9.EYJLBWFPFBCI6INRLC3RAZ21HAWUY29TIIWIAW0IJONDU1NZAZNTE5FQ.I6Z8JLXX4H1R3GNOANOYSDI0QYEU01GALNYWEZKTHS $scope.authLogin = function () {

我想在我的系统中增加限制。然后我使用JWT令牌。然后我首选statellizer作为前端

一旦用户登录系统,它将生成如下令牌

EYJ0EXAIIOIJKV1QILJHBGCIOIJIUZI1NIJ9.EYJLBWFPFBCI6INRLC3RAZ21HAWUY29TIIWIAW0IJONDU1NZAZNTE5FQ.I6Z8JLXX4H1R3GNOANOYSDI0QYEU01GALNYWEZKTHS

         $scope.authLogin = function () {
           $auth.login({
             email: $scope.email, password: $scope.password
           }).then(function(res){
             //userService.setUser(res.data.user);
             toastr.success('Successfully login ', 'Message', {
               closeButton: true
             });
             window.location = '/dashboard';
           }).catch(function onError() {
               toastr.error('Invalid email/password combination.', 'Error', {
                 closeButton: true
               });
           });
         };
'/login'  : { view: 'static/login'},
'/signup' : { view : 'static/signup'},
'/'       : { view: 'static/login' },
'GET /dashboard' : 'PageController.showDashboard', 
  'UserController':{
    '*':['jwtAuth'],
    authLog : true
   // signUp : true
  },

  'PageController': {
    '*': ['jwtAuth']
  }
但情况是当用户成功登录到系统时,它将重定向到仪表板,但令牌没有与请求绑定

其他请求仅在仪表板中正常工作

控制器中的登录功能

         $scope.authLogin = function () {
           $auth.login({
             email: $scope.email, password: $scope.password
           }).then(function(res){
             //userService.setUser(res.data.user);
             toastr.success('Successfully login ', 'Message', {
               closeButton: true
             });
             window.location = '/dashboard';
           }).catch(function onError() {
               toastr.error('Invalid email/password combination.', 'Error', {
                 closeButton: true
               });
           });
         };
'/login'  : { view: 'static/login'},
'/signup' : { view : 'static/signup'},
'/'       : { view: 'static/login' },
'GET /dashboard' : 'PageController.showDashboard', 
  'UserController':{
    '*':['jwtAuth'],
    authLog : true
   // signUp : true
  },

  'PageController': {
    '*': ['jwtAuth']
  }
路由文件

         $scope.authLogin = function () {
           $auth.login({
             email: $scope.email, password: $scope.password
           }).then(function(res){
             //userService.setUser(res.data.user);
             toastr.success('Successfully login ', 'Message', {
               closeButton: true
             });
             window.location = '/dashboard';
           }).catch(function onError() {
               toastr.error('Invalid email/password combination.', 'Error', {
                 closeButton: true
               });
           });
         };
'/login'  : { view: 'static/login'},
'/signup' : { view : 'static/signup'},
'/'       : { view: 'static/login' },
'GET /dashboard' : 'PageController.showDashboard', 
  'UserController':{
    '*':['jwtAuth'],
    authLog : true
   // signUp : true
  },

  'PageController': {
    '*': ['jwtAuth']
  }
策略文件

         $scope.authLogin = function () {
           $auth.login({
             email: $scope.email, password: $scope.password
           }).then(function(res){
             //userService.setUser(res.data.user);
             toastr.success('Successfully login ', 'Message', {
               closeButton: true
             });
             window.location = '/dashboard';
           }).catch(function onError() {
               toastr.error('Invalid email/password combination.', 'Error', {
                 closeButton: true
               });
           });
         };
'/login'  : { view: 'static/login'},
'/signup' : { view : 'static/signup'},
'/'       : { view: 'static/login' },
'GET /dashboard' : 'PageController.showDashboard', 
  'UserController':{
    '*':['jwtAuth'],
    authLog : true
   // signUp : true
  },

  'PageController': {
    '*': ['jwtAuth']
  }
我想让任何人在没有令牌的情况下都无法访问仪表板。我希望我的问题是清楚的


感谢我尝试的方法,这是错误的,因为当我们调用GET/dashboard函数时,无法将令牌与请求绑定。这种方法非常适合会话

我用了下面的方法。这对我很有效。这对用帆操纵JWT更方便