module.exports = function(app) {
  var Role = app.models.Role;

   Role.registerResolver('teamMember', function(role, context, cb) {

    function reject(msg) {
      console.log(msg);
      process.nextTick(function() {
      cb(null, false);
      });
    }

    var userId = context.accessToken.userId;
      if (!userId) {
      return reject('Invalid access token');
    }

    context.model.findById(context.modelId, function provideModel(err, model) {
      if (err || !model) { return reject('No relative model found.');}

      model.users.findById(userId, function postFind(err, users) {
        if (err || !users) {
          reject("Unauthorized!");
        } else {
          cb(null, true);
        }

      });
    });

   });
};

@@ -59,17 +59,16 @@
 ole;%0A%0A  
- 
 Role.reg
@@ -215,24 +215,26 @@
 n() %7B%0A      
+  
 cb(null, fal
@@ -300,26 +300,24 @@
 userId;%0A    
-  
 if (!userId)
@@ -477,16 +477,24 @@
 model) %7B
+%0A       
  return 
@@ -528,16 +528,23 @@
 ound.');
+%0A      
 %7D%0A%0A     
@@ -544,21 +544,318 @@
 %0A%0A      
+var 
 model
+WithUsers = null;%0A      if (model.users) %7B%0A        modelWithUsers = model;%0A      %7D%0A      if (model.account) %7B%0A        modelWithUsers = model.account;%0A      %7D%0A      if (!modelWithUsers) %7B%0A        reject('Model cannot be linked to user, so this role should fail.');%0A      %7D%0A%0A      modelWithUsers
 .users.f
@@ -1015,25 +1015,24 @@
 ;%0A        %7D%0A
-%0A
       %7D);%0A  
@@ -1029,24 +1029,25 @@
     %7D);%0A
+%0A
     %7D);%0A
 %0A   %7D);%0A
@@ -1042,15 +1042,12 @@
 %7D);%0A
-%0A 
   %7D);%0A%7D
-;
 %0A

Add support for models that have .account