mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-08 20:48:48 +00:00
Started work for having session-logins instead of sending passwords back and forth
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
function thumbnail(msg, coll, guid, offline, socket) {
|
||||
if(msg.thumbnail && msg.channel && msg.adminpass && msg.thumbnail.indexOf("i.imgur.com") > -1){
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.thumbnail) != "string" ||
|
||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||
if(msg.thumbnail && msg.channel && msg.thumbnail.indexOf("i.imgur.com") > -1){
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.thumbnail) != "string")
|
||||
{
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
@@ -23,21 +23,26 @@ function thumbnail(msg, coll, guid, offline, socket) {
|
||||
socket.emit("update_required", result);
|
||||
return;
|
||||
}
|
||||
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.zoff_id, msg.adminpass));
|
||||
db.collection(channel + "_settings").find({id: "config"}, function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(socketid, msg.pass)).digest("base64")))) {
|
||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
||||
db.collection("suggested_thumbnails").update({channel: channel}, {$set:{thumbnail: msg.thumbnail}}, {upsert:true}, function(err, docs){
|
||||
Notifications.requested_change("thumbnail", msg.thumbnail, channel);
|
||||
socket.emit("toast", "suggested_thumbnail");
|
||||
});
|
||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
||||
msg.userpass = userpass;
|
||||
msg.adminpass = adminpass;
|
||||
|
||||
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.zoff_id, msg.adminpass));
|
||||
db.collection(channel + "_settings").find({id: "config"}, function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(socketid, msg.pass)).digest("base64")))) {
|
||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
||||
db.collection("suggested_thumbnails").update({channel: channel}, {$set:{thumbnail: msg.thumbnail}}, {upsert:true}, function(err, docs){
|
||||
Notifications.requested_change("thumbnail", msg.thumbnail, channel);
|
||||
socket.emit("toast", "suggested_thumbnail");
|
||||
});
|
||||
}
|
||||
} else {
|
||||
socket.emit("auth_required");
|
||||
}
|
||||
} else {
|
||||
socket.emit("auth_required");
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
socket.emit("toast", "thumbnail_denied");
|
||||
@@ -45,9 +50,8 @@ function thumbnail(msg, coll, guid, offline, socket) {
|
||||
}
|
||||
|
||||
function description(msg, coll, guid, offline, socket) {
|
||||
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.description) != "string" ||
|
||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||
if(msg.description && msg.channel && msg.description.length < 100){
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.description) != "string") {
|
||||
var result = {
|
||||
channel: {
|
||||
expected: "string",
|
||||
@@ -69,19 +73,24 @@ function description(msg, coll, guid, offline, socket) {
|
||||
socket.emit("update_required", result);
|
||||
return;
|
||||
}
|
||||
var channel = msg.channel.toLowerCase();
|
||||
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
||||
db.collection(channel + "_settings").find({id: "config"}, function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(socketid, msg.pass)).digest("base64")))) {
|
||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
||||
db.collection("suggested_descriptions").update({channel: channel}, {$set:{description: msg.description}}, {upsert:true}, function(err, docs){
|
||||
Notifications.requested_change("description", msg.description, channel);
|
||||
socket.emit("toast", "suggested_description");
|
||||
});
|
||||
|
||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass, gotten) {
|
||||
msg.userpass = userpass;
|
||||
msg.adminpass = adminpass;
|
||||
var channel = msg.channel.toLowerCase();
|
||||
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
||||
db.collection(channel + "_settings").find({id: "config"}, function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(socketid, msg.pass)).digest("base64")))) {
|
||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
||||
db.collection("suggested_descriptions").update({channel: channel}, {$set:{description: msg.description}}, {upsert:true}, function(err, docs){
|
||||
Notifications.requested_change("description", msg.description, channel);
|
||||
socket.emit("toast", "suggested_description");
|
||||
});
|
||||
}
|
||||
} else {
|
||||
socket.emit("auth_required");
|
||||
}
|
||||
} else {
|
||||
socket.emit("auth_required");
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
socket.emit("toast", "description_denied");
|
||||
|
||||
Reference in New Issue
Block a user