// Access token to normalize email credentials UserModel.observe('access', function normalizeEmailCase(ctx, next) { if (!ctx.Model.settings.caseSensitiveEmail && ctx.query.where && ctx.query.where.email) { ctx.query.where.email = ctx.query.where.email.toLowerCase(); } next(); });
This code completely chokes if you have case insensitive email on and you try to query the user api by email address using a like query. The ctx.query.where will == {'like': 'someValue'} which is an object and not a string, so .toLowerCase is not defined which cause the entire process to crash.
A simple fix is to check whether toLowerCase exists first and let the consumer deal with making sure the query is all lowercase, or you could do a quick loop over all of the property values and lower case each. If there is a preference, I could create a pull request.
// Access token to normalize email credentials UserModel.observe('access', function normalizeEmailCase(ctx, next) { if (!ctx.Model.settings.caseSensitiveEmail && ctx.query.where && ctx.query.where.email) { ctx.query.where.email = ctx.query.where.email.toLowerCase(); } next(); });This code completely chokes if you have case insensitive email on and you try to query the user api by email address using a like query. The ctx.query.where will == {'like': 'someValue'} which is an object and not a string, so .toLowerCase is not defined which cause the entire process to crash.
A simple fix is to check whether toLowerCase exists first and let the consumer deal with making sure the query is all lowercase, or you could do a quick loop over all of the property values and lower case each. If there is a preference, I could create a pull request.