text: /*	miso permissions
  	Permit users access to controller actions based on roles 
  */
  var miso = require('../modules/miso.util.js'),
  	hasRole = function(userRoles, roles){
  		var hasRole = false;
  		//	All roles
  		if(userRoles == "*") {
  			return true;
  		}
  		//	Search each user role
  		miso.each(userRoles, function(userRole){
  			userRole = (typeof userRole !== "string")? userRole: [userRole];
  			//	Search each role
  			miso.each(roles, function(role){
  				if(userRole == role) {
  					hasRole = true;
  					return false;
  				}
  			});
  		});
  		return hasRole;
  	};
  
  //	Determine if the user has access to an APP action
  //	TODO: 
  module.exports.app = function(permissions, actionName, userRoles){
  	//	TODO: Probably need to use pass=false by default, but first:
  	//
  	//	* Add global config for pass default in server.json
  	//	* 
  	//
  	var pass = true;
  
  	//	Apply deny first, then allow.
  	if(permissions && userRoles){
  		if(permissions.deny) {
  			pass = ! hasRole(user.roles, permissions.deny);
  		}
  		if(permissions.allow) {
  			pass = hasRole(user.roles, permissions.allow);
  		}
  	}
  
  	return pass;
  };
  
  
  //	Determine if the user has access to an API action
  //	TODO: 
  module.exports.api = function(permissions, actionName, userRoles){
  	//	TODO: Probably need to use pass=false by default, but first:
  	//
  	//	* Add global config for pass default in server.json
  	//	* 
  	//
  	var pass = true;
  
  	//	Apply deny first, then allow.
  	if(permissions && userRoles){
  		if(permissions.deny) {
  			pass = ! hasRole(user.roles, permissions.deny);
  		}
  		if(permissions.allow) {
  			pass = hasRole(user.roles, permissions.allow);
  		}
  	}
  
  	return pass;
  };