我想在我的系统中增加限制。然后我使用了 JWT 令牌。然后我更喜欢前端的 statellizer。
一旦用户登录系统。它将生成这样的令牌
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6InRlc3RAZ21haWwuY29tIiwiaWF0IjoxNDU1NzAzAzNTE5fQ.I6z8jlXx4H1R3gNOAnOysdI0qyeU01GAlnYWeQZKThs
但是情况是当用户成功登录系统时。它将重定向到仪表板但令牌没有与请求绑定。
其他请求仅在仪表板中正常工作。
控制器中的登录功能
$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']
}
我想让它就像任何人都无法在没有令牌的情况下访问仪表板一样。我希望我的问题很清楚。
谢谢