Does Mean.js req.isAuthenticated error indicate failure?

I downloaded meanjs version@0.1.12. here I used two servers for an interface that used angular with its ion launch in localhost: 3000, for the backend I used meanjs.in that meanjs I created signup, signin and articles.When ever I I use toolsjs as a backend and front end, it works fine. But when I connect to another server (localhost: 3000), registration and signature work fine, but when I create articles, I get 401 unauthorized bcoz of this req.isAuthenticated () function. When I ever create an article module req.isAuthenticated () get fail.req.isAuthenticated () I dono what should I go through for this function, I included my code that someone helps me

now i am transferring data like this

$http.post('http://192.168.1.14:3000/articles', credentials).success(function(response,data,errorResponse) { // If successful we assign the response to the global user model //$scope.authentication.user =response; console.log(response); console.log(data); // And redirect to the index page $location.path('/tab/account'); }, function(response,data,errorResponse) { $scope.error = errorResponse.data.message; console.log($scope.error); console.log(data); }); 

routes:

 app.route('/articles') .get(users.requiresLogin,articles.list) .post(users.requiresLogin,articles.create); 

login verification

 /** * Require login routing middleware */ exports.requiresLogin = function(req, res, next) { //console.log(req.isAuthenticated()); console.log(req); if (!req.isAuthenticated()) { return res.status(401).send({ message: 'User is not logged in' }); } next(); }; /** * User authorizations routing middleware */ exports.hasAuthorization = function(roles) { var _this = this; console.log('sss'); return function(req, res, next) { _this.requiresLogin(req, res, function() { if (_.intersection(req.user.roles, roles).length) { return next(); } else { return res.status(403).send({ message: 'User is not authorized' }); } }); }; }; 
+6
source share
1 answer

I think I had the same problem. Be sure to check the server-side policy folder.

 roles: ['user'], allows: [{ resources: '/articles', permissions: ['get', 'post'] }, { resources: '/articles/:articlesId', permissions: ['get'] }, { resources: '/articles', permissions: ['post'] }] 

Add the path to the /articles resource and permissions.

0
source

All Articles