We are using Client Manager plugin for shutting down a client . We are using Servoy Security module . But while debugging in the Servoy Security module We are seeing that client.We are seeing some active sessions for it . Please find below the code for shutting down a client :
var clients = plugins.clientmanager.getConnectedClients();
for (var i = 0; i < clients.length; i++) {
if (clients[i].getUserName() == userEmail) {
plugins.clientmanager.shutDownClient(clients[i].getClientID());
}
}
Have you checked your if statement returns true, might require === for string comparison check and/or case sensitive.
Try placing application.output(“test”) inside for loop and if statement or application.output(clients*.getUserName()) and application.output(userEmail).*
We don’t close clients, just log some stuff, but we use getUserUID() to identify the clients, this is safer on our side because tenants and names for users, so the username is not enough.
/**
* fetch data of logged in sessions
* @param {String} userId
* @return {Array<{clientID: String, userName: String, idleDate: Date, ip: String, hostName: String, hostInfo: String}>}
* @properties={typeid:24,uuid:"3F427538-008D-4376-823C-D8EB68F37CAE"}
*/
function getUserSessionData(userId) {
var sessionIds = []
var session = plugins.clientmanager.getConnectedClients();
for (var i = 0; i < session.length; i++) {
if (session[i].getUserUID() == userId) {
sessionIds.push({clientID: session[i].getClientID(), userName: session[i].getUserName(), idleDate: session[i].getIdleTime(), ip: session[i].getHostAddress(), hostName: session[i].getHostName(), hostInfo: session[i].getHostIdentifier()})
}
}
return sessionIds;
}
Instead of creating the array with sessions you could try to kill the session. I’m not sure if you would kill the current one, you should test that.