Forcing UID value
-
I've just try to put this function in the plugin and call that directly without hooks,
plugin.getUidByAUid = function(auid, callback) { if (!auid) { return callback(null, 0); } console.log('auid param log:' + auid); db.sortedSetScore('auid:uid', auid, callback); }; plugin.getUserDataByField = function (callerUid, field, fieldValue, callback) { async.waterfall([ function (next) { if (field === 'uid') { next(null, fieldValue); } else if (field === 'auid') { plugin.getUidByAUid(fieldValue, next); } else if (field === 'username') { user.getUidByUsername(fieldValue, next); } else if (field === 'email') { user.getUidByEmail(fieldValue, next); } else { next(null, null); } }, function (uid, next) { if (!uid) { return next(null, null); } userController.getUserDataByUID(callerUid, uid, next); }, ], callback); };
than i've try each field using plugin.getUserDataByField and not userController.getUserDataByField (hook doesn't exist so was ignored) :
function (userObj, callback) { //user.getUidByEmail(String(userObj.email), callback) //user.getUserDataByUID('1','4', callback); //plugin.getUidByAUid(String(userObj.uid), callback); console.log(userObj.uid); plugin.getUserDataByField('1', 'auid', userObj.uid, function(err, userData) { console.log(userData.auid); //return callback(userData.auid, null); });
Using all field work except that auid , db.sortedSetScore('auid:uid', auid, callback) return always null
-
@julian said in Forcing UID value:
getSortedSetScore
getSortedSetScore doesn't exist it's sortedSetScore
https://github.com/NodeBB/NodeBB/blob/master/src/user/index.js#L129 -
plugin.getUidByAUid = function(auid, callback) { if (!auid) { return callback(null, 0); } db.sortedSetScore('auid:uid', auid, callback); };
return always null , so i've checked if the function was working and i've try to change db.sortedSetScore('auid:uid', auid, callback) to db.sortedSetScore('email:uid', '[email protected]' , callback) and it work .
At this point i've also checked using redis-cli for 'auid' field, it exist and has the right value.
I really don't understand what's wrong, it look db.sortedSetScore can't find 'auid' for some reason
-
@Simos the equivalent code would be
ZSCORE auid:uid 1
-
@baris so why i can get it in the hash ? auid exist ...
127.0.0.1:6379> HGETALL user:1
- "username"
- "Simos"
- "userslug"
- "simos"
- "email"
- "[email protected]"
- "joindate"
- "1542893552374"
- "lastonline"
- "1543850453258"
- "picture"
- ""
- "fullname"
- ""
- "location"
- ""
- "birthday"
- ""
- "website"
- ""
- "signature"
- ""
- "uploadedpicture"
- ""
- "profileviews"
- "2"
- "reputation"
- "0"
- "postcount"
- "1"
- "topiccount"
- "1"
- "lastposttime"
- "1542893552974"
- "banned"
- "0"
- "status"
- "online"
- "gdpr_consent"
- "0"
- "acceptTos"
- "0"
- "uid"
- "1"
- "password"
- "XXXXXXXXXXXXXXXXXXXXXXXXXX"
- "passwordExpiry"
- "0"
- "groupTitle"
- "["administrators"]"
- "auid"
- "3074"
-
@Simos said in Forcing UID value:
"auid"
"3074"It exists as part of the user hash, but if you don't save it into
auid:uid
thensortedSetScore
will always return null. You need to set it intoauid:uid
as well withdb.sortedSetAdd('auid:uid', uid, auid, callback);
-
@baris i'm losing my self again ... i've already added that value to user hash on user create, in wich part of plugin now i've to save it into auid:uid with the function you have mentioned ?
I'm new to redis ... pheraps i'm confused because i usually use mysql , but i 've understand that is completly different.