@ -169,7 +169,8 @@ app.cacheBuster = null;
});
};
app.enterRoom = function (room) {
app.enterRoom = function (room, callback) {
callback = callback || function() {};
if (socket) {
if (app.currentRoom === room) {
return;
@ -180,9 +181,12 @@ app.cacheBuster = null;
username: app.user.username,
userslug: app.user.userslug,
picture: app.user.picture
}, function(err) {
if (err) {
app.alertError(err.message);
}
app.currentRoom = room;
@ -54,10 +54,15 @@ SocketMeta.rooms.enter = function(socket, data, callback) {
if (!socket.uid) {
if (!data) {
return callback(new Error('[[error:invalid-data]]'));
if (data.enter && data.enter.startsWith('uid_') && data.enter !== 'uid_' + socket.uid) {
return callback(new Error('[[error:not-allowed]]'));
if (socket.currentRoom) {
rooms.leave(socket, socket.currentRoom);
if (socket.currentRoom.indexOf('topic') !== -1) {