I’m trying to write a dynamicHelper for Jade to check if a user is allowed to access a resource before actually accessing it. I have the module to perform the checks which returns true or false when called with the url and username of the resource to be accessed, but I can’t get the helper working with parameters?
dummy view:
if(hasAccess.check("/url", "username") == true)
li access
else
li no-access
Helper:
app.dynamicHelpers({
hasAccess: function() {
return access;
}
});
Access-function:
var access = function() {
return {
check: function(url, user) {
return mymodule.hasAccess(url, user);
}
};
};
I tried to get it done with this answer, but no luck so far.
There are a couple of things wrong there (if I understand it correctly)
It’s possible that what you’re trying to do would work using
But i haven’t run the code, so I may be completely wrong.
Good luck 🙂