Fix session data not updating correctly
This commit is contained in:
parent
d7e6db92b5
commit
833bdfa2aa
@ -304,11 +304,15 @@ Client.prototype.updateSession = function(token, ip, request) {
|
||||
friendlyAgent += ` on ${agent.os.name} ${agent.os.version}`;
|
||||
}
|
||||
|
||||
client.config.sessions[token] = _.assign({
|
||||
client.config.sessions[token] = _.assign(client.config.sessions[token], {
|
||||
lastUse: Date.now(),
|
||||
ip: ip,
|
||||
agent: friendlyAgent,
|
||||
}, client.config.sessions[token]);
|
||||
});
|
||||
|
||||
client.manager.updateUser(client.name, {
|
||||
sessions: client.config.sessions
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.setPassword = function(hash, callback) {
|
||||
@ -318,7 +322,6 @@ Client.prototype.setPassword = function(hash, callback) {
|
||||
password: hash
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
log.error("Failed to update password of", client.name, err);
|
||||
return callback(false);
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ ClientManager.prototype.updateUser = function(name, opts, callback) {
|
||||
|
||||
fs.writeFile(Helper.getUserConfigPath(name), newUser, (err) => {
|
||||
if (err) {
|
||||
log.error("Failed to update user", err);
|
||||
log.error(`Failed to update user ${colors.green(name)} (${err})`);
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
|
@ -407,10 +407,6 @@ function initializeClient(socket, client, token, lastMessage) {
|
||||
|
||||
client.manager.updateUser(client.name, {
|
||||
sessions: client.config.sessions
|
||||
}, (err) => {
|
||||
if (err) {
|
||||
log.error("Failed to update sessions for", client.name, err);
|
||||
}
|
||||
});
|
||||
|
||||
_.map(client.attachedClients, (attachedClient, socketId) => {
|
||||
@ -461,14 +457,6 @@ function initializeClient(socket, client, token, lastMessage) {
|
||||
|
||||
client.updateSession(token, getClientIp(socket.request), socket.request);
|
||||
|
||||
client.manager.updateUser(client.name, {
|
||||
sessions: client.config.sessions
|
||||
}, (err) => {
|
||||
if (err) {
|
||||
log.error("Failed to update sessions for", client.name, err);
|
||||
}
|
||||
});
|
||||
|
||||
sendInitEvent(token);
|
||||
});
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user