Closed BlackHawkNL closed 8 years ago
Thanks for opening an issue. Could you provide some code to demonstrate how to reproduce this error?
Just a simple example
server.route({
method: 'GET',
path: '/permcheck',
config: {
auth: {
strategy: 'simple',
scope: 'admin'
}
},
handler: function(request, reply) {
var credentials = request.auth.credentials;
if (credentials.roles.admin.hasPermissionTo('adminarea')) {
return reply(true);
} else {
reply(false);
}
}
});
Ah! We need to update that wiki page, hasPermissionTo
requires a callback. Here is a working version of what you posted.
server.route({
method: 'GET',
path: '/permcheck',
config: {
auth: {
strategy: 'simple',
scope: 'admin'
}
},
handler: function(request, reply) {
const credentials = request.auth.credentials;
credentials.roles.admin.hasPermissionTo('adminarea', (err, allowed) => {
if (err) {
// hydrating failed
}
reply(allowed);
});
}
});
Hi,
Im having some troubles with the permissions check, and cant figure out where its going wrong. For some reason when i check for permissions i keep getting the following error:
TypeError: callback is not a function at hydrateGroups (/server/models/admin.js:115:13) at Async.auto (/server/models/admin.js:90:13)
I used the simple example thats in the wiki, and ofcourse made sure that the permission is assigned to a group and that the admin making the API call is assigned to that specific group.
Is there a work around for this? or can some one help me on the right direction.
Thanks, BlackHawk