User.getUidByEmail cannot find email?



  • Hello,

    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?

    Thanks,

    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.


  • Admin

    You have to update other objects in the database. Namely email:uid and 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);
    


  • @baris said in User.getUidByEmail cannot find email?:

    email:uid

    Thanks @boris

    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?

    Thanks,


  • Admin

    Yeah pretty much, email:uid sorted has the user id as the score and the lowercase email as the value.
    email:sorted has a score 0 and the value is useremail + ':' + userid It 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..

    Thanks again.


Log in to reply
 


Star

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.