From cf015d92005eaed1fec5d530cbb98571cad0de86 Mon Sep 17 00:00:00 2001 From: Carlo Minotti <50220438+minottic@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:20:31 +0200 Subject: [PATCH] Check for user existance --- helm/configs/backend/login-callbacks.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/helm/configs/backend/login-callbacks.js b/helm/configs/backend/login-callbacks.js index 4789554..c87306e 100644 --- a/helm/configs/backend/login-callbacks.js +++ b/helm/configs/backend/login-callbacks.js @@ -3,11 +3,12 @@ exports.accessGroupsToProfile = function (req, done) { return async function (err, user, identity, token) { - await user.identities.destroyAll({and: [ - {provider: identity.provider}, - {id: {neq: identity.id}}, - {userId: user.id} - ]}); + if (user && user.identities) + await user.identities.destroyAll({and: [ + {provider: identity.provider}, + {id: {neq: identity.id}}, + {userId: user.id} + ]}); identity.updateAttributes({ "profile": { accessGroups: identity.profile._json.pgroups,