Forcing UID value
-
@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. -
@baris my problem problem is :
how i can call db.sortedSetAdd('auid:uid', uid, auid, callback); on action:user.create ? i don't have uid until user is already created.
@baris said in Forcing UID value:
You need to load the value from the user hash and call db.sortedSetAdd('auid:uid', uid, auid, callback);
i mean some command to do it using redis-cli
-
Hooks won't let you fix existing users, you need to write custom script to run through all the users and fix the association.
You can use this template
/*globals require, console, process */ 'use strict'; var nconf = require('nconf'); var async = require('async'); nconf.file({ file: 'config.json' }); nconf.defaults({ base_dir: __dirname, views_dir: './build/public/templates', }); var db = require('./src/database'); db.init(function(err) { if (err) { console.log("NodeBB could not connect to your database. Error: " + err.message); process.exit(); } fixAssociation(function (err) { if (err) { console.error(err); process.exit(); } console.log('done'); process.exit(); }); }); function fixAssociation(callback) { // implement code }
-
@baris thanks.
I've just 2 new problems :
-
https://github.com/SimosNap/nodebb-plugin-login-anope/blob/master/library.js#L116
it look it can't change email what's wrong ? -
on IRC nicknames can also contain same special chars for example "nick`out" , i've seen that if an user switch to one of this nickname, i've seen that nodebb preserve the old username, any suggestion for this ?
-