Thanks to both of you for your quick help!
Both solution do work indeed. As baris pointed out, my failure was returning values from async functions.
Here is a working example for each solution:
var Groups = module.parent.require('./groups');
Groups.isMember(uid, 'administrators', function(err, isMember) {
if (err) { next(err); }
if (isMember) {
winston.info('user is an administrator');
Groups.join('administrators', uid);
} else {
winston.info('user is no administrator');
Groups.leave('administrators', uid);
}
});
var User = module.parent.require('./user');
var Groups = module.parent.require('./groups');
User.isAdministrator(uid, function(err, isAdmin) {
if (err) { next(err); }
if (isAdmin) {
winston.info('user is an administrator');
Groups.join('administrators', uid);
} else {
winston.info('user is no administrator');
Groups.leave('administrators', uid);
}
});