node.js - Sailsjs policies -
i having trouble figuring out sails policies, follow tutorial still can't make work.
in policies.js file:
module.exports.policies = { '*':true, userscontroller:{ '*':false, signin: 'skipauthenticated' } }
and in authenticated.js file:
module.exports = function skipauthenticated(req, res, ok){ console.log("testing"); if (req.session.authenticated){ console.log("testing"); return ok(); } else { return res.send("you not permitted perform action.", 403); } }
but policy not trigger. appreciated.
if take @ section entitled how protect controllers policies? describes policy name matches name of file in api/policies. problem actual policy name "authenticated" (you said authenticated.js) , policy name you're trying use in acl "skipauthenticated."
so can either change policy file name skipauthenticated.js or can change acl reflect actual policy name.
http://sailsjs.org/#!documentation/policies
you can apply 1 or more policies given controller or action. file in /policies folder (e.g. authenticated.js) referable in acl (config/policies.js) filename minus extension, (e.g. 'authenticated').
Comments
Post a Comment