mirror of
https://github.com/thelounge/thelounge
synced 2024-11-14 08:17:16 +00:00
Update user file once on auth
This commit is contained in:
parent
c1920eb566
commit
def56dc694
3 changed files with 10 additions and 12 deletions
|
@ -316,6 +316,7 @@ Client.prototype.updateSession = function(token, ip, request) {
|
|||
});
|
||||
|
||||
client.manager.updateUser(client.name, {
|
||||
browser: client.config.browser,
|
||||
sessions: client.config.sessions,
|
||||
});
|
||||
};
|
||||
|
|
|
@ -190,8 +190,10 @@ ClientManager.prototype.updateUser = function(name, opts, callback) {
|
|||
_.assign(user, opts);
|
||||
const newUser = JSON.stringify(user, null, "\t");
|
||||
|
||||
|
||||
// Do not touch the disk if object has not changed
|
||||
if (currentUser === newUser) {
|
||||
console.log("same");
|
||||
return callback ? callback() : true;
|
||||
}
|
||||
|
||||
|
|
|
@ -664,15 +664,19 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
|
|||
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.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);
|
||||
|
||||
sendInitEvent(newToken);
|
||||
});
|
||||
} else {
|
||||
client.updateSession(token, getClientIp(socket), socket.request);
|
||||
sendInitEvent(null);
|
||||
}
|
||||
}
|
||||
|
@ -734,16 +738,9 @@ function performAuthentication(data) {
|
|||
let client;
|
||||
let token = null;
|
||||
|
||||
const finalInit = () => {
|
||||
const finalInit = () =>
|
||||
initializeClient(socket, client, token, data.lastMessage || -1, data.openChannel);
|
||||
|
||||
if (!Helper.config.public) {
|
||||
client.manager.updateUser(client.name, {
|
||||
browser: client.config.browser,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const initClient = () => {
|
||||
// Configuration does not change during runtime of TL,
|
||||
// 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)) {
|
||||
token = providedToken;
|
||||
|
||||
client.updateSession(providedToken, getClientIp(socket), socket.request);
|
||||
|
||||
return authCallback(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue