I have implemented feathers-authentication-hooks
in my project and it is working verifying against a custom user column containing a role. Now I want to have it working with more then one role per user. I've trying several formats in the database column, but all have failed:
Data formats (exact format per line):
role1, role2
role1; role2
[role1,role2]
{"column_name": ["role1","role2"]}
does someone know what I need to do?
Most hooks in that package can be implemented manually often with the same amount of code and less time than it takes to read the documentation. In this case for your example with a custom hook like this:
const { Unauthorized } = require('feathers-errors');
return function() {
return function(context) {
if(context.params.user.roles.indexOf('admin') === -1) {
throw new Unauthorized('You are not allowed to access this');
}
}
}