From baf084802141b77d6a2ebb08d344f196201a8d42 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 7 Jun 2024 17:43:36 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A7=20fix:=20LDAP=20login=20after=20Us?= =?UTF-8?q?er=20verification=20changes=20(#3003)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/strategies/ldapStrategy.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/strategies/ldapStrategy.js b/api/strategies/ldapStrategy.js index 440c8482f..344d20d83 100644 --- a/api/strategies/ldapStrategy.js +++ b/api/strategies/ldapStrategy.js @@ -1,5 +1,5 @@ const LdapStrategy = require('passport-ldapauth'); -const { findUser, createUser } = require('~/models/userMethods'); +const { findUser, createUser, updateUser } = require('~/models/userMethods'); const fs = require('fs'); const ldapOptions = { @@ -49,6 +49,8 @@ const ldapLogin = new LdapStrategy(ldapOptions, async (userinfo, done) => { emailVerified: true, name: fullName, }; + const userId = await createUser(user); + user._id = userId; } else { user.provider = 'ldap'; user.ldapId = userinfo.uid; @@ -56,7 +58,7 @@ const ldapLogin = new LdapStrategy(ldapOptions, async (userinfo, done) => { user.name = fullName; } - await createUser(user); + user = await updateUser(user._id, user); done(null, user); } catch (err) {