From 0b39df777b22da5518c9e64a7625276a4fbf68ae Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Thu, 24 Jul 2014 11:34:52 -0400 Subject: [PATCH] Signin: Proper notification if user not found closes #3374 - If user object is returned but undefined, we'll display a human-readable error notification (user model) - If user object is returned, but the user is inactive or invited (but not activated), we'll display a human-readable error notification --- core/server/models/user.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/server/models/user.js b/core/server/models/user.js index a4be909f92..9081b96f55 100644 --- a/core/server/models/user.js +++ b/core/server/models/user.js @@ -487,9 +487,12 @@ User = ghostBookshelf.Model.extend({ var self = this, s; return this.getByEmail(object.email).then(function (user) { - if (!user || user.get('status') === 'invited' || user.get('status') === 'invited-pending' + if (!user) { + return when.reject(new errors.NotFoundError('There is no user with that email address.')); + } + if (user.get('status') === 'invited' || user.get('status') === 'invited-pending' || user.get('status') === 'inactive') { - return when.reject(new errors.NotFoundError('NotFound')); + return when.reject(new Error('The user with that email address is inactive.')); } if (user.get('status') !== 'locked') { return nodefn.call(bcrypt.compare, object.password, user.get('password')).then(function (matched) { @@ -512,7 +515,7 @@ User = ghostBookshelf.Model.extend({ }, function (error) { if (error.message === 'NotFound' || error.message === 'EmptyResponse') { - return when.reject(new Error('There is no user with that email address.')); + return when.reject(new errors.NotFoundError('There is no user with that email address.')); } return when.reject(error);