From 111ed802cfd7dee74e76ad44882a305ba5921503 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 29 Jan 2020 12:47:48 -0500 Subject: [PATCH] fix: onSuccessfulLogin not working In scenarios where onSuccessfulLogin was not called in the SSO plugin, core's calling of onSuccessfulLogin was prematurely returning, because it was checking the wrong value. This commit fixes the issue by checking a different value. --- src/controllers/authentication.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 56a0a11f20..7bf27139fd 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -316,8 +316,12 @@ authenticationController.doLogin = async function (req, uid) { }; authenticationController.onSuccessfulLogin = async function (req, uid) { - // If already called once, return prematurely - if (req.res.locals.user) { + /* + * Older code required that this method be called from within the SSO plugin. + * That behaviour is no longer required, onSuccessfulLogin is now automatically + * called in NodeBB core. However, if already called, return prematurely + */ + if (req.loggedIn) { return true; }