Closed marcosnils closed 10 years ago
The reason the default policy of '*': 'isAuthenticated'
doesn't work for the views/main/index.jade
is that the routes.js
file points to a static view rather than a Controller. As far as I can tell, the default policy wont work for static views.
When I added a controller action and changed the '/'
route for the policy the default policy appeared to work:
// MainController.js
module.exports = {
index: function (req, res) {
return res.view();
},
//...
};
// routes.js
module.exports.routes = {
'/' : 'MainController.index',
//...
};
You might ask the SailsJs group if they know of an alternate way of protecting static routes if this workaround doesn't fit your use case. Hope this helps.
hey @cgmartin I think that I can live with adding a controller which redirects to the view I'm expecting. I'll address this question to the sailsjs group though to see what I get.
Thanks for the feedback!.
I've tried setting '*': 'isAuthenticated' in the policies.js file but for some reason the index.jade view does not get protected.
Is there an easy way to do this?
Thanks!.