From 546737e6be020d427fcbcc02c27b4638b3cbc941 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Thu, 23 Jun 2016 00:55:15 +0530 Subject: [PATCH] fix password validate crash --- common/models/user.js | 5 +++++ server/boot/a-extendUser.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/common/models/user.js b/common/models/user.js index 62d7bb63f1d..3a6e4468341 100644 --- a/common/models/user.js +++ b/common/models/user.js @@ -80,6 +80,11 @@ module.exports = function(User) { if (user.progressTimestamps.length === 0) { user.progressTimestamps.push({ timestamp: Date.now() }); } + // this is workaround for preventing a server crash + // refer strongloop/loopback/#1364 + if (user.password === '') { + user.password = null; + } } return next(); }); diff --git a/server/boot/a-extendUser.js b/server/boot/a-extendUser.js index 8cdbd169721..57e318d14cd 100644 --- a/server/boot/a-extendUser.js +++ b/server/boot/a-extendUser.js @@ -53,6 +53,11 @@ module.exports = function(app) { User.beforeRemote('create', function(ctx, user, next) { var body = ctx.req.body; if (body) { + // this is workaround for preventing a server crash + // refer strongloop/loopback/#1364 + if (body.password === '') { + body.password = null; + } body.emailVerified = false; } next();