When a user is removed from a project, kill their VFS session

pull/365/head
Tim Robinson 2016-09-29 00:04:24 +00:00
rodzic f46f266c0a
commit 586ea62b29
1 zmienionych plików z 25 dodań i 3 usunięć

Wyświetl plik

@ -336,9 +336,31 @@ function plugin(options, imports, register) {
}
}
function handlePublish(vfs, messageString) {
var message = JSON.parse(messageString);
switch (message.action) {
case "remove_member":
handleRemoveProjectMember(vfs, message);
break;
default:
break;
}
}
function handleRemoveProjectMember(vfs, message) {
if (vfs.uid !== message.body.uid) return;
console.log("Removing ", vfs.id, " for user ", vfs.uid, " project ", vfs.pid, " from the vfs connection cache");
// Remove after 2s so client has time to recieve final "You've been removed" PubSub message.
setTimeout(function() {
cache.remove(vfs.id);
}, 2000);
}
register(null, {
"vfs.server": {
get section() { return section; }
get section() { return section; },
get handlePublish() { return handlePublish; }
}
});
}