From 2bdbb47286c2fd66809e617c43aa08179083b0ba Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Mon, 20 Feb 2017 21:48:31 +0100 Subject: [PATCH] Fix crash when a user does not yet have an username --- src/user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/user.js b/src/user.js index c4c8c2d77..3343c02ac 100644 --- a/src/user.js +++ b/src/user.js @@ -223,7 +223,8 @@ function verify(userId, password, callback) { getUser(userId, function (error, user) { if (error) return callback(error); - if (verifyGhost(user.username, password)) return callback(null, user); + // for just invited users the username may be still null + if (user.username && verifyGhost(user.username, password)) return callback(null, user); var saltBinary = new Buffer(user.salt, 'hex'); crypto.pbkdf2(password, saltBinary, CRYPTO_ITERATIONS, CRYPTO_KEY_LENGTH, CRYPTO_DIGEST, function (error, derivedKey) {