Updated socket.id for chromecastlistening on mobile

This commit is contained in:
Kasper Rynning-Tønnesen
2017-09-12 20:19:13 +02:00
parent a6a7c86975
commit a2e7bb7ffb
5 changed files with 15 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
module.exports = function() {
io.on('connection', function(socket){
socket.zoff_id = socket.id;
socket.emit("get_list");
var guid = Functions.hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]);
@@ -14,7 +15,7 @@ module.exports = function() {
var socketid = socket.id;
var socketid = socket.zoff_id;
var coll;
var in_list = false;
var short_id;
@@ -44,6 +45,7 @@ module.exports = function() {
if(connected_users_channel.users.indexOf(msg.guid) > -1) {
guid = msg.guid;
socketid = msg.socket_id;
socket.zoff_id = socketid;
coll = msg.channel;
in_list = true;
chromecast_object = true;

View File

@@ -16,7 +16,7 @@ var now_playing = function(list, fn, socket) {
}
var list = function(msg, guid, coll, offline, socket) {
var socketid = socket.id;
var socketid = socket.zoff_id;
if(typeof(msg) === 'object' && msg !== undefined && msg !== null && msg.hasOwnProperty("channel") && msg.hasOwnProperty('pass'))
{
@@ -68,7 +68,7 @@ var list = function(msg, guid, coll, offline, socket) {
}
var skip = function(list, guid, coll, offline, socket) {
var socketid = socket.id;
var socketid = socket.zoff_id;
if(list !== undefined && list !== null && list !== "")
{

View File

@@ -1,5 +1,5 @@
var add = function(arr, coll, guid, offline, socket) {
var socketid = socket.id;
var socketid = socket.zoff_id;
if(typeof(arr) === 'object' && arr !== undefined && arr !== null && arr !== "" && !isNaN(parseInt(arr.duration)))
{
@@ -146,7 +146,7 @@ var add = function(arr, coll, guid, offline, socket) {
}
var voteUndecided = function(msg, coll, guid, offline, socket) {
var socketid = socket.id;
var socketid = socket.zoff_id;
if(typeof(msg) === 'object' && msg !== undefined && msg !== null){
if(coll == "" || coll == undefined || coll == null || !msg.hasOwnProperty("adminpass") || !msg.hasOwnProperty("pass") || !msg.hasOwnProperty("id")) {
@@ -185,7 +185,7 @@ var voteUndecided = function(msg, coll, guid, offline, socket) {
}
var shuffle = function(msg, coll, guid, offline, socket) {
var socketid = socket.id;
var socketid = socket.zoff_id;
if(msg.hasOwnProperty('adminpass') && msg.adminpass !== undefined && msg.adminpass !== null)
{
if(coll == "" || coll == undefined || coll == null) {
@@ -260,7 +260,7 @@ function del(params, socket, socketid) {
}
var delete_all = function(msg, coll, guid, offline, socket) {
var socketid = socket.id;
var socketid = socket.zoff_id;
if(typeof(msg) == 'object' && msg.hasOwnProperty('channel') && msg.hasOwnProperty('adminpass') && msg.hasOwnProperty('pass')) {
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
var hash_userpass = Functions.decrypt_string(socketid, msg.pass);

View File

@@ -20,7 +20,7 @@ var password = function(inp, coll, guid, offline, socket) {
}
uncrypted = pw;
pw = Functions.decrypt_string(socket.id, pw);
pw = Functions.decrypt_string(socket.zoff_id, pw);
Functions.check_inlist(coll, guid, socket, offline);
@@ -28,7 +28,7 @@ var password = function(inp, coll, guid, offline, socket) {
{
opw = inp.oldpass;
}
opw = Functions.decrypt_string(socket.id, opw);
opw = Functions.decrypt_string(socket.zoff_id, opw);
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
if(docs !== null && docs.length !== 0)
@@ -93,7 +93,7 @@ var conf = function(params, coll, guid, offline, socket) {
var adminpass = params.adminpass;
var skipping = params.skipping;
var shuffling = params.shuffling;
var userpass = Functions.decrypt_string(socket.id, params.userpass);
var userpass = Functions.decrypt_string(socket.zoff_id, params.userpass);
if((!params.userpass_changed && frontpage) || (params.userpass_changed && userpass == "")) {
userpass = "";
@@ -105,7 +105,7 @@ var conf = function(params, coll, guid, offline, socket) {
if(params.description) description = params.description;
if(adminpass !== "") {
hash = Functions.hash_pass(Functions.decrypt_string(socket.id, adminpass));
hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, adminpass));
} else {
hash = adminpass;
}

View File

@@ -3,7 +3,7 @@ var thumbnail = function(msg, coll, guid, offline, socket) {
msg.thumbnail = msg.thumbnail.replace(/^https?\:\/\//i, "");
if(msg.thumbnail.substring(0,2) != "//") msg.thumbnail = "//" + msg.thumbnail;
var channel = msg.channel.toLowerCase();
var hash = Functions.hash_pass(Functions.decrypt_string(socket.id, msg.adminpass));
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
db.collection(channel).find({views:{$exists:true}}, function(err, docs){
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
@@ -23,7 +23,7 @@ var thumbnail = function(msg, coll, guid, offline, socket) {
var description = function(msg, coll, guid, offline, socket) {
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
var channel = msg.channel.toLowerCase();
var hash = Functions.hash_pass(Functions.decrypt_string(socket.id, msg.adminpass));
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
db.collection(channel).find({views:{$exists:true}}, function(err, docs){
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){