Commit 8308b642 authored by Killian Kemps's avatar Killian Kemps

Force page reload from socket when user not identified

parent 9c70457b
......@@ -60,6 +60,9 @@
$('#m').val('');
return false;
});
socket.on('reload page', function(){
document.location.reload(true);
});
socket.on('chat message', function(msg){
$('#messages').append($('<li>').text(msg));
......
......@@ -107,7 +107,14 @@ function getAppstateName(email) {
io.on('connection', function(socket){
var cookieArray = socket.request.headers.cookie.split('=');
var email = sessions.util.decode(cookieOptions, cookieArray[ cookieArray.length - 1 ]).content.email;
var cookie = sessions.util.decode(cookieOptions, cookieArray[ cookieArray.length - 1 ]);
if (cookie === undefined) {
console.log('Sending reload event');
socket.emit('reload page');
}
var email = cookie.content.email;
console.log('Socket email: ', email);
var currentUser = users[email];
......@@ -159,6 +166,10 @@ io.on('connection', function(socket){
}
).catch(function(err) {
console.log('An error occured: ', err);
if (err === 'currentUser is undefined') {
console.log('Sending reload event');
socket.emit('reload page');
}
});
socket.on('chat message', function(msg){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment