这是带有csrf令牌的表单
<form name="form" method="POST" ng-submit="login(user)" novalidate>
<input type="hidden" ng-model="user._csrf" name="_csrf" value="<%= _csrf %>" />
......
....
</form>
如何通过http.post
请求
$http.defaults.withCredentials = true;
$scope.login = function (user) {
//user login as post
$http.post('/login',user).then(function (response) {
console.log(response.data);
});
}
当我提交上述请求时,我将收到csrf token not found错误
以下是关于csrf http://sailsjs.com/documentation/concepts/security/csrf
的sails.js文档