mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	Trying way of emulating cookies for chromecast
This commit is contained in:
		@@ -252,6 +252,22 @@ function getSessionChatPass(id, callback) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function setChromecastHost(id, other_id, callback) {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        if(id == "empty" || id == undefined) {
 | 
				
			||||||
 | 
					            callback();
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        connected_db.collection(id).update({_id: list}, {"chromecast": true, id: id}, {upsert: true}, function(e, docs) {
 | 
				
			||||||
 | 
					            callback(true);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    } catch(e) {
 | 
				
			||||||
 | 
					        callback(false);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function setSessionUserPass(id, userpass, list, callback) {
 | 
					function setSessionUserPass(id, userpass, list, callback) {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        if(id == "empty" || id == undefined) {
 | 
					        if(id == "empty" || id == undefined) {
 | 
				
			||||||
@@ -277,10 +293,16 @@ function getSessionAdminUser(id, list, callback) {
 | 
				
			|||||||
            var userpass = "";
 | 
					            var userpass = "";
 | 
				
			||||||
            var adminpass = "";
 | 
					            var adminpass = "";
 | 
				
			||||||
            if(d.length > 0) {
 | 
					            if(d.length > 0) {
 | 
				
			||||||
                if(d[0].userpass != undefined) userpass = d[0].userpass;
 | 
					                if(d.hasOwnProperty("chromecast") && d.chromecast) {
 | 
				
			||||||
                if(d[0].adminpass != undefined) adminpass = d[0].adminpass;
 | 
					                    getSessionAdminUser(d.id, list, callback);
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    if(d[0].userpass != undefined) userpass = d[0].userpass;
 | 
				
			||||||
 | 
					                    if(d[0].adminpass != undefined) adminpass = d[0].adminpass;
 | 
				
			||||||
 | 
					                    callback(userpass, adminpass, true);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                callback(userpass, adminpass, true);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            callback(userpass, adminpass, true);
 | 
					 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
    } catch(e) {
 | 
					    } catch(e) {
 | 
				
			||||||
        callback("", "", false);
 | 
					        callback("", "", false);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,6 +89,9 @@ module.exports = function() {
 | 
				
			|||||||
                    db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) {
 | 
					                    db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) {
 | 
				
			||||||
                        console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel)
 | 
					                        console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel)
 | 
				
			||||||
                        if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) {
 | 
					                        if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) {
 | 
				
			||||||
 | 
					                            Functions.setChromecastHost(socket.cookie_id, msg.guid, function(results) {
 | 
				
			||||||
 | 
					                                console.log("setChromecastHost: ", results);
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
                            socket.cookie_id = msg.guid;
 | 
					                            socket.cookie_id = msg.guid;
 | 
				
			||||||
                            guid = msg.guid;
 | 
					                            guid = msg.guid;
 | 
				
			||||||
                            socketid = msg.socket_id;
 | 
					                            socketid = msg.socket_id;
 | 
				
			||||||
@@ -96,6 +99,7 @@ module.exports = function() {
 | 
				
			|||||||
                            if(msg.hasOwnProperty("channel")) {
 | 
					                            if(msg.hasOwnProperty("channel")) {
 | 
				
			||||||
                                msg.channel = Functions.encodeChannelName(msg.channel);
 | 
					                                msg.channel = Functions.encodeChannelName(msg.channel);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            coll = msg.channel.toLowerCase();//.replace(/ /g,'');
 | 
					                            coll = msg.channel.toLowerCase();//.replace(/ /g,'');
 | 
				
			||||||
                            coll = Functions.removeEmojis(coll).toLowerCase();
 | 
					                            coll = Functions.removeEmojis(coll).toLowerCase();
 | 
				
			||||||
                            coll = filter.clean(coll);
 | 
					                            coll = filter.clean(coll);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,12 +34,10 @@ try {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
router.use(recaptcha.middleware.render, function(req, res, next) {
 | 
					router.use(recaptcha.middleware.render, function(req, res, next) {
 | 
				
			||||||
    console.log("middleware render");
 | 
					 | 
				
			||||||
    next(); // make sure we go to the next routes and don't stop here
 | 
					    next(); // make sure we go to the next routes and don't stop here
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
router.route('/:channel_name').get(function(req, res, next){
 | 
					router.route('/:channel_name').get(function(req, res, next){
 | 
				
			||||||
    console.log("channel_name get");
 | 
					 | 
				
			||||||
    channel(req, res, next);
 | 
					    channel(req, res, next);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -49,12 +47,10 @@ router.route('/r/:base64data').get(function(req, res, next){
 | 
				
			|||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
router.route('/').get(function(req, res, next){
 | 
					router.route('/').get(function(req, res, next){
 | 
				
			||||||
    console.log("/ get");
 | 
					 | 
				
			||||||
    root(req, res, next);
 | 
					    root(req, res, next);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
router.route('/').post(function(req, res, next){
 | 
					router.route('/').post(function(req, res, next){
 | 
				
			||||||
    console.log("/ post");
 | 
					 | 
				
			||||||
    root(req, res, next);
 | 
					    root(req, res, next);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user