diff --git a/common/models/promo.js b/common/models/promo.js index 4dedb9a940..ec4970d461 100644 --- a/common/models/promo.js +++ b/common/models/promo.js @@ -1,4 +1,4 @@ -import { isAlphanumeric, isHexadecimal } from 'validator'; +import { isAlphanumeric, isMongoId } from 'validator'; import debug from 'debug'; const log = debug('fcc:models:promo'); @@ -6,16 +6,16 @@ const log = debug('fcc:models:promo'); export default function promo(Promo) { Promo.getButton = function getButton(id, code, type = 'isNot') { const Job = Promo.app.models.Job; - if (!id || !isHexadecimal(id)) { + if (!id || !isMongoId('' + id)) { return Promise.reject(new Error( 'Must include job id' )); } if ( - !isAlphanumeric(code) && + !isAlphanumeric('' + code) && type && - !isAlphanumeric(type) + !isAlphanumeric('' + type) ) { return Promise.reject(new Error( 'Code or Type should be an alphanumeric' diff --git a/server/boot/challenge.js b/server/boot/challenge.js index d793b9fbfd..b5350d418a 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -431,7 +431,7 @@ module.exports = function(app) { challengeId = badIdMap[challengeId]; } - if (!isMongoId(challengeId)) { + if (!isMongoId('' + challengeId)) { challengeId = null; } @@ -456,7 +456,7 @@ module.exports = function(app) { challengeId = badIdMap[challengeId]; } - if (!isMongoId(challengeId)) { + if (!isMongoId('' + challengeId)) { challengeId = null; } diff --git a/server/boot/story.js b/server/boot/story.js index 8857290bc0..55eb3a52c2 100755 --- a/server/boot/story.js +++ b/server/boot/story.js @@ -343,7 +343,7 @@ module.exports = function(app) { } var url = req.body.data.url; - if (!validator.isURL(url)) { + if (!validator.isURL('' + url)) { req.flash('errors', { msg: "The URL you submitted doesn't appear valid" });