Fixed issues regarding forcing restarts, and userpasswords not working correctly

This commit is contained in:
Kasper Rynning-Tønnesen
2017-05-16 16:44:48 +02:00
parent 0db90fe416
commit 7e83116a61
5 changed files with 34 additions and 16 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -72,6 +72,7 @@ var Admin = {
msg="Skipping is disabled the first 10 seconds."; msg="Skipping is disabled the first 10 seconds.";
break; break;
case "correctpass": case "correctpass":
adminpass = Crypt.get_pass(chan.toLowerCase()) == undefined ? Crypt.crypt_pass(Crypt.tmp_pass) : Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()));
msg="Correct password. You now have access to the sacred realm of The Admin."; msg="Correct password. You now have access to the sacred realm of The Admin.";
$("#thumbnail_form").css("display", "inline-block"); $("#thumbnail_form").css("display", "inline-block");
$("#description_form").css("display", "inline-block"); $("#description_form").css("display", "inline-block");
@@ -95,10 +96,11 @@ var Admin = {
Materialize.toast(msg, 4000); Materialize.toast(msg, 4000);
}, },
pw: function(msg) pw: function(msg) {
{
w_p = false; w_p = false;
adminpass = Crypt.tmp_pass; if(adminpass == undefined || adminpass == "") {
adminpass = Crypt.get_pass(chan.toLowerCase());
}
names = ["vote","addsongs","longsongs","frontpage", "allvideos", names = ["vote","addsongs","longsongs","frontpage", "allvideos",
"removeplay", "skip", "shuffle", "userpass"]; "removeplay", "skip", "shuffle", "userpass"];
@@ -301,7 +303,18 @@ var Admin = {
shuffling = form.shuffle.checked; shuffling = form.shuffle.checked;
var pass_send = userpass == '' ? userpass : CryptoJS.SHA256(userpass).toString(); var pass_send = userpass == '' ? userpass : CryptoJS.SHA256(userpass).toString();
configs = { configs = {
channel: chan.toLowerCase(), voting: voting, addsongs: addsongs, longsongs: longsongs, frontpage: frontpage, allvideos: allvideos, removeplay: removeplay, adminpass: adminpass, skipping: skipping, shuffling: shuffling, userpass: pass_send, userpass_changed: userpass_changed channel: chan.toLowerCase(),
voting: voting,
addsongs: addsongs,
longsongs: longsongs,
frontpage: frontpage,
allvideos: allvideos,
removeplay: removeplay,
adminpass: adminpass,
skipping: skipping,
shuffling: shuffling,
userpass: Crypt.crypt_pass(pass_send),
userpass_changed: userpass_changed
}; };
Crypt.set_userpass(chan.toLowerCase(), CryptoJS.SHA256(userpass).toString()); Crypt.set_userpass(chan.toLowerCase(), CryptoJS.SHA256(userpass).toString());

View File

@@ -989,7 +989,7 @@ $(document).on("change", ".password_protected", function(e) {
} else { } else {
userpass = ""; userpass = "";
if(!$(".change_user_pass").hasClass("hide")) $(".change_user_pass").addClass("hide"); if(!$(".change_user_pass").hasClass("hide")) $(".change_user_pass").addClass("hide");
Admin.save(false); Admin.save(true);
} }
}); });

View File

@@ -898,9 +898,9 @@ io.on('connection', function(socket){
var adminpass = params.adminpass; var adminpass = params.adminpass;
var skipping = params.skipping; var skipping = params.skipping;
var shuffling = params.shuffling; var shuffling = params.shuffling;
var userpass = params.userpass; var userpass = decrypt_string(socketid, params.userpass);
if((!params.userpass_changed && frontpage) || (!params.userpass_changed && userpass == "")) { if((!params.userpass_changed && frontpage) || (params.userpass_changed && userpass == "")) {
userpass = ""; userpass = "";
} else if(params.userpass_changed && userpass != "") { } else if(params.userpass_changed && userpass != "") {
frontpage = false; frontpage = false;
@@ -915,10 +915,9 @@ io.on('connection', function(socket){
hash = adminpass; hash = adminpass;
} }
db.collection(coll).find({views:{$exists:true}}, function(err, docs){ db.collection(coll).find({views:{$exists:true}}, function(err, docs){
if(docs !== null && docs.length !== 0 && docs[0].adminpass === "" || docs[0].adminpass == hash) if(docs !== null && docs.length !== 0 && (docs[0].adminpass === "" || docs[0].adminpass == hash)) {
{ var obj = {
db.collection(coll).update({views:{$exists:true}}, { addsongs:addsongs,
$set:{addsongs:addsongs,
allvideos:allvideos, allvideos:allvideos,
frontpage:frontpage, frontpage:frontpage,
skip:skipping, skip:skipping,
@@ -928,8 +927,14 @@ io.on('connection', function(socket){
longsongs:longsongs, longsongs:longsongs,
adminpass:hash, adminpass:hash,
desc: description, desc: description,
userpass: userpass, };
} if(params.userpass_changed) {
obj["userpass"] = userpass;
} else if (frontpage) {
obj["userpass"] = "";
}
db.collection(coll).update({views:{$exists:true}}, {
$set:obj
}, function(err, docs){ }, function(err, docs){
db.collection(coll).find({views:{$exists:true}}, function(err, docs){ db.collection(coll).find({views:{$exists:true}}, function(err, docs){
if(docs[0].adminpass !== "") docs[0].adminpass = true; if(docs[0].adminpass !== "") docs[0].adminpass = true;
@@ -944,7 +949,7 @@ io.on('connection', function(socket){
{upsert:true}, function(err, docs){}); {upsert:true}, function(err, docs){});
}); });
}); });
} else{ } else {
socket.emit("toast", "wrongpass"); socket.emit("toast", "wrongpass");
} }
}); });