Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion routes/captcha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function captchas () {
}

captchas.verifyCaptcha = () => (req: Request, res: Response, next: NextFunction) => {
CaptchaModel.findOne({ where: { captchaId: req.body.captchaId } }).then((captcha: Captcha | null) => {
CaptchaModel.findOne({ where: { captchaId: Number(req.body.captchaId) } }).then((captcha: Captcha | null) => {
if ((captcha != null) && req.body.captcha === captcha.answer) {
next()
} else {
Expand Down
2 changes: 1 addition & 1 deletion routes/likeProductReviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function productReviews () {
() => {
// Artificial wait for timing attack challenge
setTimeout(function () {
db.reviews.findOne({ _id: id }).then((review: Review) => {
db.reviews.findOne({ _id: { $eq: id } }).then((review: Review) => {
const likedBy = review.likedBy
likedBy.push(user.data.email)
let count = 0
Expand Down
2 changes: 1 addition & 1 deletion routes/showProductReviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function productReviews () {

// Measure how long the query takes, to check if there was a nosql dos attack
const t0 = new Date().getTime()
db.reviews.find({ $where: 'this.product == ' + id }).then((reviews: Review[]) => {
db.reviews.find({ product: { $eq: id } }).then((reviews: Review[]) => {
const t1 = new Date().getTime()
challengeUtils.solveIf(challenges.noSqlCommandChallenge, () => { return (t1 - t0) > 2000 })
const user = security.authenticatedUsers.from(req)
Expand Down