mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-04 21:15:55 +01:00
closes #4950
This commit is contained in:
@@ -153,5 +153,8 @@
|
||||
"no-users-in-room": "No users in this room",
|
||||
"cant-kick-self": "You can't kick yourself from the group",
|
||||
"no-users-selected": "No user(s) selected",
|
||||
"invalid-home-page-route": "Invalid home page route"
|
||||
"invalid-home-page-route": "Invalid home page route",
|
||||
|
||||
"invalid-session": "Session Mismatch",
|
||||
"invalid-session-text": "It looks like your login session is no longer active, or no longer matches with the server. Please refresh this page."
|
||||
}
|
||||
|
||||
@@ -117,6 +117,10 @@ app.cacheBuster = null;
|
||||
};
|
||||
|
||||
app.alertError = function (message, timeout) {
|
||||
if (message === '[[error:invalid-session]]') {
|
||||
return app.handleInvalidSession();
|
||||
}
|
||||
|
||||
app.alert({
|
||||
title: '[[global:alert.error]]',
|
||||
message: message,
|
||||
@@ -125,6 +129,28 @@ app.cacheBuster = null;
|
||||
});
|
||||
};
|
||||
|
||||
app.handleInvalidSession = function() {
|
||||
if (app.flags && app.flags._sessionRefresh) {
|
||||
return;
|
||||
}
|
||||
|
||||
app.flags = app.flags || {};
|
||||
app.flags._sessionRefresh = true;
|
||||
|
||||
require(['translator'], function(translator) {
|
||||
translator.translate('[[error:invalid-session-text]]', function(translated) {
|
||||
bootbox.alert({
|
||||
title: '[[error:invalid-session]]',
|
||||
message: translated,
|
||||
closeButton: false,
|
||||
callback: function() {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
app.enterRoom = function (room, callback) {
|
||||
callback = callback || function() {};
|
||||
if (socket && app.user.uid && app.currentRoom !== room) {
|
||||
|
||||
@@ -28,6 +28,12 @@ app.isConnected = false;
|
||||
setTimeout(socket.connect.bind(socket), parseInt(config.reconnectionDelay, 10) * 10);
|
||||
});
|
||||
|
||||
socket.on('checkSession', function(uid) {
|
||||
if (parseInt(uid, 10) !== parseInt(app.user.uid, 10)) {
|
||||
app.handleInvalidSession();
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('event:banned', onEventBanned);
|
||||
|
||||
socket.on('event:alert', app.alert);
|
||||
|
||||
@@ -56,6 +56,8 @@ var ratelimit = require('../middleware/ratelimit');
|
||||
} else {
|
||||
socket.join('online_guests');
|
||||
}
|
||||
|
||||
io.sockets.sockets[socket.id].emit('checkSession', socket.uid);
|
||||
}
|
||||
|
||||
function onMessage(socket, payload) {
|
||||
|
||||
Reference in New Issue
Block a user