                 if sysPermRec
                     @dbOperation 'removeUser', user, null, (err) ->
                         # Remove from cache
-                        next(err, @remove(user))
+                        next(err, null)
                 else next(null, null)
         ], callback
 

                if not sysPermRec
                    @dbOperation 'addUser', user, null, (err) =>
                        # Add to cache
                        next(err, @add(user))
                else next(null, sysPermRec)
            (sysPermRec, next) =>
                @setSysPerm

CacheManager           = require('./cache_manager')
SystemPermissions      = require('./system_permissions')

# the permission might be changed by other workers.
# caching is disabled
class UserPermissionManager
    collectionName = "Permissions"

    constructor : (@mongoInterface, callback) ->
        @dbOperation('addIndex', null, {_email:1}, 
            (err) =>
                callback(err,this)
