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}, {
|
||||
$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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user