Skip to content
Luis Eduardo Brito edited this page Aug 29, 2013 · 1 revision

You can secure controllers using access policies, defined in ```/api/policies/[name].js``.

For example, the /api/policies/authenticated.js

var response = require("../adapters/response");

module.exports = function(req, res, ok) {

	if(req.cookies.authenticated == "true") {

		ok();
	}

	else {
		response(res).json({

			result: "error",
			description: "you're not logged in"
		});
	}
}

In the end of the code block, don't forget to call ok(), without this action, the access will be blocked.

Clone this wiki locally