@pitaj here you are 😉rgigante created this issue in NodeBB/NodeBB closed Failed to delete a user if user has started a chat #9503
User.getUidByEmail cannot find email?
I just had to do a mass update on the user objects in the DB, i updated all of the user emails to our new emails. When i look in the DB i can see that the email field has been updated correctly but the User.getUidByEmail in my AUTH plugin cannot find any of the new emails..
User.getUidByEmail can however still see the old emails, is there another index somewhere that i need to update?
UPDATE Incase it was case sensitive i updated all of the emails to uppercase and then forced the users email address to upper case in the login plugin. Still the same.. it can see the old emails but not the new.
You have to update other objects in the database. Namely
email:sorted. These are created like this on user creation.
async.parallel([ async.apply(db.sortedSetAdd, 'email:uid', userData.uid, userData.email.toLowerCase()), async.apply(db.sortedSetAdd, 'email:sorted', 0, userData.email.toLowerCase() + ':' + userData.uid), ], next);
I saw these earlier but couldnt find a way that they were linked to the user object.. Is there a way to link them back now that i have already changed the email in the user object?
Link them back as in find them based on some info in the user object so that i can update them?
hmm.. looks like the email:uid object has a score equal to the user number in the _key field of the user object and the email:sorted has the value field ending in email:id (id that seems to equal the user number in the _key field of the user object. I guess thats how id link them?
Yeah pretty much,
email:uidsorted has the user id as the score and the lowercase email as the value.
email:sortedhas a score 0 and the value is
useremail + ':' + useridIt is used to search users by email.
@baris Yup this worked.. i was able to update everything.. I thought i was going crazy for a while earlier when it was still signing in with the old emails..