Update user file once on auth
This commit is contained in:
parent
c1920eb566
commit
def56dc694
@ -316,6 +316,7 @@ Client.prototype.updateSession = function(token, ip, request) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.manager.updateUser(client.name, {
|
client.manager.updateUser(client.name, {
|
||||||
|
browser: client.config.browser,
|
||||||
sessions: client.config.sessions,
|
sessions: client.config.sessions,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -190,8 +190,10 @@ ClientManager.prototype.updateUser = function(name, opts, callback) {
|
|||||||
_.assign(user, opts);
|
_.assign(user, opts);
|
||||||
const newUser = JSON.stringify(user, null, "\t");
|
const newUser = JSON.stringify(user, null, "\t");
|
||||||
|
|
||||||
|
|
||||||
// Do not touch the disk if object has not changed
|
// Do not touch the disk if object has not changed
|
||||||
if (currentUser === newUser) {
|
if (currentUser === newUser) {
|
||||||
|
console.log("same");
|
||||||
return callback ? callback() : true;
|
return callback ? callback() : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,15 +664,19 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
|
|||||||
socket.emit("commands", inputs.getCommands());
|
socket.emit("commands", inputs.getCommands());
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!Helper.config.public && token === null) {
|
if (Helper.config.public) {
|
||||||
|
sendInitEvent(null);
|
||||||
|
} else if (token === null) {
|
||||||
client.generateToken((newToken) => {
|
client.generateToken((newToken) => {
|
||||||
client.attachedClients[socket.id].token = token = client.calculateTokenHash(newToken);
|
token = client.calculateTokenHash(newToken);
|
||||||
|
client.attachedClients[socket.id].token = token;
|
||||||
|
|
||||||
client.updateSession(token, getClientIp(socket), socket.request);
|
client.updateSession(token, getClientIp(socket), socket.request);
|
||||||
|
|
||||||
sendInitEvent(newToken);
|
sendInitEvent(newToken);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
client.updateSession(token, getClientIp(socket), socket.request);
|
||||||
sendInitEvent(null);
|
sendInitEvent(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -734,16 +738,9 @@ function performAuthentication(data) {
|
|||||||
let client;
|
let client;
|
||||||
let token = null;
|
let token = null;
|
||||||
|
|
||||||
const finalInit = () => {
|
const finalInit = () =>
|
||||||
initializeClient(socket, client, token, data.lastMessage || -1, data.openChannel);
|
initializeClient(socket, client, token, data.lastMessage || -1, data.openChannel);
|
||||||
|
|
||||||
if (!Helper.config.public) {
|
|
||||||
client.manager.updateUser(client.name, {
|
|
||||||
browser: client.config.browser,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const initClient = () => {
|
const initClient = () => {
|
||||||
// Configuration does not change during runtime of TL,
|
// Configuration does not change during runtime of TL,
|
||||||
// and the client listens to this event only once
|
// and the client listens to this event only once
|
||||||
@ -827,8 +824,6 @@ function performAuthentication(data) {
|
|||||||
if (Object.prototype.hasOwnProperty.call(client.config.sessions, providedToken)) {
|
if (Object.prototype.hasOwnProperty.call(client.config.sessions, providedToken)) {
|
||||||
token = providedToken;
|
token = providedToken;
|
||||||
|
|
||||||
client.updateSession(providedToken, getClientIp(socket), socket.request);
|
|
||||||
|
|
||||||
return authCallback(true);
|
return authCallback(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user