mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
More fixes
This commit is contained in:
5
package-lock.json
generated
5
package-lock.json
generated
@@ -2436,11 +2436,6 @@
|
||||
"version": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
|
||||
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
|
||||
},
|
||||
"q": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
|
||||
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc="
|
||||
},
|
||||
"qs": {
|
||||
"version": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz",
|
||||
"integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg="
|
||||
|
||||
@@ -56,7 +56,6 @@
|
||||
"nodemailer": "^4.0.1",
|
||||
"passport": "^0.4.0",
|
||||
"passport-local": "^1.0.0",
|
||||
"q": "^1.5.1",
|
||||
"redis": "^2.8.0",
|
||||
"request": "^2.72.0",
|
||||
"socket.io": "^2.0.4",
|
||||
|
||||
@@ -134,29 +134,32 @@ function all_chat(msg, guid, offline, socket) {
|
||||
}
|
||||
|
||||
function namechange(data, guid, socket, tried) {
|
||||
if(!data.hasOwnProperty("name") || data.name.length > 10 ||
|
||||
!data.hasOwnProperty("channel") || typeof(data.name) != "string" ||
|
||||
if(!data.hasOwnProperty("channel") ||
|
||||
typeof(data.channel) != "string") return;
|
||||
var pw = "";
|
||||
var new_password;
|
||||
var first = false;
|
||||
Functions.getSessionChatPass(Functions.getSession(socket), function(name, pass) {
|
||||
var name = data.name;
|
||||
if(data.hasOwnProperty("first")) {
|
||||
first = data.first;
|
||||
}
|
||||
if(data.hasOwnProperty("password")) {
|
||||
pw = data.password;
|
||||
new_password = false;
|
||||
} else if(data.hasOwnProperty("new_password") && data.hasOwnProperty("old_password")) {
|
||||
pw = data.old_password;
|
||||
new_password = Functions.decrypt_string(socket.zoff_id, data.new_password);
|
||||
}
|
||||
if(data.hasOwnProperty("first") && data.first) {
|
||||
pw = pass;
|
||||
name = name;
|
||||
data.name = name;
|
||||
data.password = pass;
|
||||
new_password = false;
|
||||
} else {
|
||||
var name = data.name;
|
||||
if(data.hasOwnProperty("first")) {
|
||||
first = data.first;
|
||||
}
|
||||
if(data.hasOwnProperty("password")) {
|
||||
pw = data.password;
|
||||
new_password = false;
|
||||
} else if(data.hasOwnProperty("new_password") && data.hasOwnProperty("old_password")) {
|
||||
pw = data.old_password;
|
||||
new_password = Functions.decrypt_string(socket.zoff_id, data.new_password);
|
||||
}
|
||||
}
|
||||
|
||||
var password = Functions.decrypt_string(socket.zoff_id, pw);
|
||||
db.collection("registered_users").find({"_id": name.toLowerCase()}, function(err, docs) {
|
||||
var accepted_password = false;
|
||||
@@ -178,6 +181,9 @@ function namechange(data, guid, socket, tried) {
|
||||
Functions.setSessionChatPass(Functions.getSession(socket), name.toLowerCase(), data.new_password, function() {
|
||||
db.collection("registered_users").update({"_id": name.toLowerCase(), password: Functions.hash_pass(password)}, {$set: {password: Functions.hash_pass(new_password)}}, function() {});
|
||||
});
|
||||
} else {
|
||||
Functions.setSessionChatPass(Functions.getSession(socket), name.toLowerCase(), data.password, function() {
|
||||
});
|
||||
}
|
||||
}
|
||||
if(accepted_password) {
|
||||
@@ -204,7 +210,9 @@ function namechange(data, guid, socket, tried) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
socket.emit('name', {type: "name", accepted: false});
|
||||
Functions.removeSessionChatPass(Functions.getSession(socket), function() {
|
||||
socket.emit('name', {type: "name", accepted: false});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -206,7 +206,7 @@ function getSessionChatPass(id, callback) {
|
||||
var pass = "";
|
||||
if(d[0].name != undefined) name = d[0].name;
|
||||
if(d[0].password != undefined) pass = d[0].password;
|
||||
callback(name, password);
|
||||
callback(name, pass);
|
||||
return;
|
||||
} else {
|
||||
callback("", "", false);
|
||||
@@ -266,8 +266,21 @@ function removeSessionChatPass(id, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function removeSessionAdminPass(id, channel, callback) {
|
||||
if(id == "empty") {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
connected_db.collection(id).remove({_id: channel}, function() {
|
||||
callback();
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.getSessionChatPass = getSessionChatPass;
|
||||
module.exports.setSessionChatPass = setSessionChatPass;
|
||||
module.exports.removeSessionAdminPass = removeSessionAdminPass;
|
||||
module.exports.removeSessionChatPass = removeSessionChatPass;
|
||||
module.exports.setSessionAdminPass = setSessionAdminPass;
|
||||
module.exports.setSessionUserPass = setSessionUserPass;
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = function() {
|
||||
});
|
||||
|
||||
socket.on("logout", function() {
|
||||
Functions.setSessionAdminPass(Functions.getSession(socket), "", coll, function() {})
|
||||
Functions.removeSessionAdminPass(Functions.getSession(socket), "", coll, function() {})
|
||||
});
|
||||
|
||||
socket.on('chromecast', function(msg) {
|
||||
|
||||
@@ -83,6 +83,7 @@ var Admin = {
|
||||
/*if(Crypt.get_pass(chan.toLowerCase())) {*/
|
||||
//Crypt.remove_pass(chan.toLowerCase());
|
||||
Admin.display_logged_out();
|
||||
console.log(Admin.logged_in);
|
||||
if(Admin.logged_in) {
|
||||
socket.emit("logout");
|
||||
Materialize.toast("Logged out", 4000);
|
||||
|
||||
@@ -131,6 +131,8 @@ var Channel = {
|
||||
|
||||
Crypt.init();
|
||||
|
||||
Chat.namechange("", true, true);
|
||||
|
||||
setup_auth_listener();
|
||||
|
||||
if(Crypt.get_offline()){
|
||||
|
||||
@@ -4,7 +4,7 @@ var Chat = {
|
||||
all_received: 0,
|
||||
chat_help: ["/name <new name> <password> to register and save a password for a nickname", "/name <new name> <new_password> <old_password> to change the password on a nickname", "/removename to logout"],//, "There are no commands.. As of now!"],
|
||||
|
||||
namechange: function(data, first) {
|
||||
namechange: function(data, first, initial) {
|
||||
var input = data.split(" ");
|
||||
if(input.length == 2) {
|
||||
var name = input[0];
|
||||
@@ -17,14 +17,14 @@ var Chat = {
|
||||
var new_password = input[1];
|
||||
var old_password = input[2];
|
||||
|
||||
|
||||
|
||||
|
||||
new_password = Crypt.crypt_chat_pass(new_password);
|
||||
old_password = Crypt.crypt_chat_pass(old_password);
|
||||
|
||||
socket.emit("namechange", {name: name, channel: chan.toLowerCase(), new_password: new_password, old_password: old_password});
|
||||
} else {
|
||||
|
||||
} else if(first) {
|
||||
socket.emit("namechange", {channel: chan.toLowerCase(), initial: initial, first: true});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -30,11 +30,6 @@ var Crypt = {
|
||||
|
||||
Hostcontroller.change_enabled(conf_arr.remote);
|
||||
if(conf_arr.width != 100) Player.set_width(conf_arr.width);
|
||||
if(conf_arr.name !== undefined && conf_arr.name !== "" && conf_arr.chat_pass !== undefined && conf_arr.chat_pass !== ""){
|
||||
setTimeout(function() {
|
||||
Chat.namechange(conf_arr.name + " " + conf_arr.chat_pass, true);
|
||||
}, 100); //to take height for delay on establishing connection
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -199,10 +199,8 @@ $().ready(function(){
|
||||
/*if(chan != undefined && (Crypt.get_pass(chan.toLowerCase()) !== undefined && Crypt.get_pass(chan.toLowerCase()) !== "")){
|
||||
emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
|
||||
}*/
|
||||
if(chan != undefined && conf_arr.name !== undefined && conf_arr.name !== "" && conf_arr.chat_pass !== undefined && conf_arr.chat_pass !== ""){
|
||||
setTimeout(function() {
|
||||
Chat.namechange(conf_arr.name + " " + conf_arr.chat_pass, true);
|
||||
}, 100); //to take height for delay on establishing connection
|
||||
if(chan != undefined) {
|
||||
Chat.namechange("", true, true);
|
||||
}
|
||||
$(".connect_error").fadeOut(function(){
|
||||
$(".connect_error").remove();
|
||||
|
||||
Reference in New Issue
Block a user