Added a try-again for commands with password if there exists an adminass saved

This commit is contained in:
Kasper Rynning-Tønnesen
2018-02-28 15:40:55 +01:00
parent 7b66575ea8
commit 2e8ef6739c
5 changed files with 54 additions and 13 deletions

View File

@@ -61,6 +61,19 @@ var Admin = {
msg=Helper.rnd(["The song was skipped", "I have skipped a song", "Skipped to the beat", "Skipmaster3000", "They see me skippin', they hatin'"]);
break;
case "listhaspass":
if(!tried_again && lastCommand != undefined && lastCommand.length > 0) {
if(Crypt.get_pass() != undefined) {
tried_again = true;
if(lastCommand.length == 1) {
socket.emit(lastCommand[0]);
} else if(lastCommand.length == 2) {
socket.emit(lastCommand[0], lastCommand[1]);
}
lastCommand = [];
return;
}
}
tried_again = false;
msg=Helper.rnd(["I'm sorry, but you have to be an admin to do that!", "Only admins can do that", "You're not allowed to do that, try logging in!", "I can't let you do that", "Please log in to do that"]);
Crypt.remove_pass(chan.toLowerCase());
Admin.display_logged_out();
@@ -80,6 +93,19 @@ var Admin = {
$("#import").removeClass("hide");
break;
case "noskip":
if(!tried_again && lastCommand != undefined && lastCommand.length > 0) {
if(Crypt.get_pass() != undefined) {
tried_again = true;
if(lastCommand.length == 1) {
socket.emit(lastCommand[0]);
} else if(lastCommand.length == 2) {
socket.emit(lastCommand[0], lastCommand[1]);
}
lastCommand = [];
return;
}
}
tried_again = false;
msg=Helper.rnd(["Only Admins can skip songs, peasant!", "You have to log in to skip songs on this channel", "Try clicking the settings icon and logging in before you skip"]);
break;
case "alreadyskip":
@@ -89,6 +115,7 @@ var Admin = {
msg="Skipping is disabled the first 10 seconds.";
break;
case "correctpass":
tried_again = false;
adminpass = Crypt.get_pass(chan.toLowerCase()) == undefined ? Crypt.tmp_pass : Crypt.get_pass(chan.toLowerCase());
msg="Correct password. You now have access to the sacred realm of The Admin.";
$("#thumbnail_form").css("display", "inline-block");
@@ -172,16 +199,16 @@ var Admin = {
}
Admin.set_conf(msg[0]);
if(msg[0].adminpass !== "" && (Crypt.get_pass(chan.toLowerCase()) !== undefined && Admin.beginning && Crypt.get_pass(chan.toLowerCase()) !== "")){
socket.emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
Admin.beginning = false;
}
},
pass_save: function() {
if(!w_p) {
socket.emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase(), oldpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase(), oldpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
} else {
socket.emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase()});
emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase()});
}
},
@@ -329,7 +356,7 @@ var Admin = {
};
Crypt.set_userpass(chan.toLowerCase(), CryptoJS.SHA256(userpass).toString());
socket.emit("conf", configs);
emit("conf", configs);
},
hide_settings: function() {
@@ -338,7 +365,7 @@ var Admin = {
shuffle: function() {
if(!offline) {
socket.emit('shuffle', {adminpass: adminpass !== undefined ? Crypt.crypt_pass(adminpass) : "", channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
emit('shuffle', {adminpass: adminpass !== undefined ? Crypt.crypt_pass(adminpass) : "", channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
} else {
for(var x = 0; x < full_playlist.length; x++){
var num = Math.floor(Math.random()*1000000);

View File

@@ -118,7 +118,7 @@ function chromecastListener(evt, data) {
if(offline){
Player.playNext();
} else {
socket.emit("skip", {error: json_parsed.data_code, id: json_parsed.videoId, pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
emit("skip", {error: json_parsed.data_code, id: json_parsed.videoId, pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
}
break;
case 1:
@@ -370,6 +370,18 @@ function change_offline(enabled, already_offline){
}
}
function emit() {
lastCommand = [];
for(var i = 0; i < arguments.length; i++) {
lastCommand.push(arguments[i]);
}
if(arguments.length == 1) {
socket.emit(arguments[0]);
} else {
socket.emit(arguments[0], arguments[1]);
}
}
function before_toast(){
if($('.toast').length > 0) {
var toastElement = $('.toast').first()[0];

View File

@@ -535,7 +535,7 @@ var List = {
vote: function(id, vote) {
if(!offline || (vote == "del" && (hasadmin && (!w_p && adminpass != "")))){
socket.emit('vote', {channel: chan, id: id, type: vote, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
emit('vote', {channel: chan, id: id, type: vote, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
} else {
if(vote == "pos"){
List.voted_song(id, (new Date()).getTime()/1000);
@@ -548,7 +548,7 @@ var List = {
skip: function(way) {
if(!offline){
socket.emit('skip', {pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), id:video_id, channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
emit('skip', {pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), id:video_id, channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
} else {
if(way) {
Player.playNext();

View File

@@ -13,6 +13,8 @@ var was_stopped = false;
var timed_remove_check;
var slider_type = "horizontal";
var programscroll = false;
var lastCommand;
var tried_again = false;
var userscroll = false;
var gotten_np = false;
var frontpage = 1;
@@ -186,7 +188,7 @@ $().ready(function(){
socket.emit("offline", {status: true, channel: chan != undefined ? chan.toLowerCase() : ""});
}
if(chan != undefined && (Crypt.get_pass(chan.toLowerCase()) !== undefined && Crypt.get_pass(chan.toLowerCase()) !== "")){
socket.emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: 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() {
@@ -366,7 +368,7 @@ $(document).on("click", ".pagination-results a", function(e) {
$(document).on("click", ".accept-delete", function(e) {
e.preventDefault();
socket.emit("delete_all", {channel: chan.toLowerCase(), adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
emit("delete_all", {channel: chan.toLowerCase(), adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
$("#delete_song_alert").modal("close");
});
@@ -459,13 +461,13 @@ $(document).on("click", "#offline-mode", function(e){
$(document).on("submit", "#thumbnail_form", function(e){
e.preventDefault();
socket.emit("suggest_thumbnail", {channel: chan, thumbnail: $("#chan_thumbnail").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
emit("suggest_thumbnail", {channel: chan, thumbnail: $("#chan_thumbnail").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
$("#chan_thumbnail").val("");
});
$(document).on("submit", "#description_form", function(e){
e.preventDefault();
socket.emit("suggest_description", {channel: chan, description: $("#chan_description").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
emit("suggest_description", {channel: chan, description: $("#chan_description").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
$("#chan_description").val("");
});

View File

@@ -449,7 +449,7 @@ var Search = {
List.vote(id, "pos");
}
} else {
socket.emit("add", {id: id, start: start, end: end, title: title, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
emit("add", {id: id, start: start, end: end, title: title, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
}//[id, decodeURIComponent(title), adminpass, duration, playlist]);
},