From eddf8a3a33cde7d373775713cae9a431322b673d Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Tue, 30 Jan 2018 21:06:34 +0100 Subject: [PATCH] Fix uncaught exception for non-existent user Since we added user management it's possible to get non-existent users which can cause a crash of the Backend server. Signed-off-by: Sheogorath --- lib/web/auth/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/web/auth/index.js b/lib/web/auth/index.js index db5ff11d..9ab62c25 100644 --- a/lib/web/auth/index.js +++ b/lib/web/auth/index.js @@ -21,6 +21,11 @@ passport.deserializeUser(function (id, done) { id: id } }).then(function (user) { + // Don't die on non-existent user + if (user == null) { + return done(null, false, { message: 'Invalid UserID' }) + } + logger.info('deserializeUser: ' + user.id) return done(null, user) }).catch(function (err) {