Fixed some unhandled exceptions

This commit is contained in:
Kasper Rynning-Tønnesen
2018-05-29 19:37:22 +02:00
parent 803ecb6a5b
commit 637006ab73
2 changed files with 8 additions and 4 deletions

View File

@@ -137,7 +137,7 @@ function findSimilar(msg, channel, broadcast, callback) {
db.collection(channel).update({"id": msg.id}, {
$set: element
}, function(err, docs) {
if(docs.nModified == 1 && broadcast) {
if(docs && docs.hasOwnProperty("nModified") && docs.nModified == 1 && broadcast) {
element.new_id = element.id;
element.id = msg.id;
if(!callback) {

View File

@@ -1203,9 +1203,13 @@ function incrementToken(token) {
}
router.route('/api/color').post(function(req, res) {
var origin = req.get("origin").replace("https://", "").replace("http://", "");
var allowed = ["client.localhost", "localhost", "zoff.me", "client.zoff.me", "zoff.no", "client.zoff.no"];
if(allowed.indexOf(origin) < 0) {
try {
var origin = req.get("origin").replace("https://", "").replace("http://", "");
var allowed = ["client.localhost", "localhost", "zoff.me", "client.zoff.me", "zoff.no", "client.zoff.no"];
if(allowed.indexOf(origin) < 0) {
throw "Wrong origin";
}
} catch(e) {
res.sendStatus(403);
return;
}