klark-js-plugins
Advanced tools
Comparing version 1.0.10 to 1.0.12
{ | ||
"name": "klark-js-plugins", | ||
"version": "1.0.10", | ||
"version": "1.0.12", | ||
"description": "Plugin modules for KlarkJS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -30,2 +30,3 @@ 'use strict'; | ||
var filters = opts && opts.filters; | ||
var uniqueBy = opts && opts.uniqueBy; | ||
@@ -45,2 +46,6 @@ var q; | ||
if (uniqueBy) { | ||
cursor.distinct(uniqueBy); | ||
} | ||
if (pagination) { | ||
@@ -71,3 +76,3 @@ if (pagination.page) { | ||
return new RegExp(value, "i"); | ||
} else if (_.isNumber(value) || _.isBoolean(value)) { | ||
} else if (_.isNumber(value) || _.isBoolean(value) || _.get(value, '_bsontype') === 'ObjectID') { | ||
return value; | ||
@@ -74,0 +79,0 @@ } else if (_.isDate(value)) { |
@@ -48,3 +48,4 @@ 'use strict'; | ||
pagination: res.locals.params.pagination, | ||
filters: res.locals.params.filters | ||
filters: res.locals.params.filters, | ||
uniqueBy: res.locals.params.uniqueBy | ||
}; | ||
@@ -51,0 +52,0 @@ |
@@ -44,3 +44,3 @@ 'use strict'; | ||
} | ||
} | ||
}//uniqueBy | ||
@@ -55,2 +55,9 @@ function checkPossibleModelQueryParameters(model, req, res) { | ||
if (req.query.uniqueBy) { | ||
const indexOfUniqueKey = pathnames.indexOf(req.query.uniqueBy); | ||
if (indexOfUniqueKey !== -1) { | ||
res.locals.params.uniqueBy = req.query.uniqueBy; | ||
} | ||
} | ||
var filters = {}; | ||
@@ -57,0 +64,0 @@ var partialValidations = _.map(pathnames, function(pathname) { |
@@ -34,2 +34,3 @@ 'use strict'; | ||
schema.methods.getSafely = getSafely; | ||
schema.methods.updateLoginInfo = updateLoginInfo; | ||
schema.statics.verifyAccount = verifyAccount; | ||
@@ -55,2 +56,8 @@ schema.statics.invalidateAccount = invalidateAccount; | ||
function updateLoginInfo() { | ||
++this.totalLogins; | ||
this.lastLogin = new Date(); | ||
return this.save(); | ||
} | ||
function invalidateAccount(id, validationToken) { | ||
@@ -77,3 +84,2 @@ var q = { | ||
} | ||
}); |
@@ -81,3 +81,3 @@ 'use strict'; | ||
var isInvalid = _.find(path.validators, function(validatorModel) { | ||
return !validatorModel.validator(opt.value); | ||
return !validatorModel.validator(path.cast(opt.value)); | ||
}); | ||
@@ -84,0 +84,0 @@ |
@@ -186,3 +186,3 @@ 'use strict'; | ||
res.locals.data = krkMiddlewarePermissions.createJWT(user); | ||
user.updateLoginInfo(); | ||
next(); | ||
@@ -189,0 +189,0 @@ }) |
73161
1803