mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Fixed some unhandled exceptions
This commit is contained in:
@@ -137,7 +137,7 @@ function findSimilar(msg, channel, broadcast, callback) {
|
|||||||
db.collection(channel).update({"id": msg.id}, {
|
db.collection(channel).update({"id": msg.id}, {
|
||||||
$set: element
|
$set: element
|
||||||
}, function(err, docs) {
|
}, function(err, docs) {
|
||||||
if(docs.nModified == 1 && broadcast) {
|
if(docs && docs.hasOwnProperty("nModified") && docs.nModified == 1 && broadcast) {
|
||||||
element.new_id = element.id;
|
element.new_id = element.id;
|
||||||
element.id = msg.id;
|
element.id = msg.id;
|
||||||
if(!callback) {
|
if(!callback) {
|
||||||
|
|||||||
@@ -1203,9 +1203,13 @@ function incrementToken(token) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
router.route('/api/color').post(function(req, res) {
|
router.route('/api/color').post(function(req, res) {
|
||||||
|
try {
|
||||||
var origin = req.get("origin").replace("https://", "").replace("http://", "");
|
var origin = req.get("origin").replace("https://", "").replace("http://", "");
|
||||||
var allowed = ["client.localhost", "localhost", "zoff.me", "client.zoff.me", "zoff.no", "client.zoff.no"];
|
var allowed = ["client.localhost", "localhost", "zoff.me", "client.zoff.me", "zoff.no", "client.zoff.no"];
|
||||||
if(allowed.indexOf(origin) < 0) {
|
if(allowed.indexOf(origin) < 0) {
|
||||||
|
throw "Wrong origin";
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
res.sendStatus(403);
|
res.sendStatus(403);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user