• i've made a fork of nodebb-plugin-login-mysite ( https://github.com/SimosNap/nodebb-plugin-login-anope ) to login to the forum using IRC anope account. On IRC users can change both username and email so UID is the only things i can refer for account updates

  • @baris do you have any suggestions for my purpose ?

  • GNU/Linux Admin

    I'd recommend against updating the uid, but letting NodeBB handle uids on its own. If you want to save the id of the user, then you should save it as a different value into the user hash instead...

  • @julian it's only some days i'm using nodebb and i'm new to redis too, do you mean create a new field in user table ? If so how do ?

  • GNU/Linux Admin

    In the fork of your login plugin, you should be able to save the remoteId into the user hash on the user.create call.

  • @julian Pheraps i miss something , i don't see an user hash field in user table :

    [ { uid: 4,
    username: 'antani',
    userslug: 'antani',
    picture: '',
    status: 'online',
    postcount: 0,
    reputation: 0,
    'email:confirmed': 0,
    lastonline: 1542925209728,
    flags: null,
    banned: 0,
    'banned:expire': 0,
    joindate: 1542925209728,
    uploadedpicture: undefined,
    'icon:text': 'A',
    'icon:bgColor': '#2196f3',
    joindateISO: '2018-11-22T22:20:09.728Z',
    lastonlineISO: '2018-11-22T22:20:09.728Z',
    banned_until: 0,
    banned_until_readable: 'Not Banned',
    administrator: false } ]

  • Global Moderator Plugin & Theme Dev

    @Simos what you just posted is what Julian referred to by "user hash". He was saying "hash table" otherwise called an object or a dictionary.

  • @PitaJ i've try to add the remoteid on user.create :

            if (!_uid) {
                    remoteid: userObj.uid,
                    username: userObj.display,
                    email: userObj.email
                }, callback);
            } else {
                callback(null, _uid)

    I suppose it don't add the remoteid value because remoteid field doesn't exist right ?

  • NodeBB

    You will need a plugin to save the remoteid into the user hash, so in your plugin listen for 'filter:user.create' here is how it should look.

    myPlugin.filterUserCreate = function (hookData, callback) {
        hookData.user.remoteid = hookData.data.remoteid;
        callback(null, hookData);

  • Thanks ! Why i can get it with user.getUserFields but not with user.getUser ?

  • Is there any existent function to get uid having a field value ? (in my case external uid)

  • GNU/Linux Admin

    .getUserField() should work, though you will need to implement the whitelist as @baris has mentioned.

  • @julian it look getUserField() need nodebb uid i've to get userdata having the remoteid (the customfield i've added)

    plugin.filterUserCreate = function (data, callback) {
    data.user.auid = data.data.auid;
    callback(null, data);

    plugin.whitelistFields = function(data, callback) {
    callback(null, data);

  • Global Moderator Plugin & Theme Dev

    Yeah you'll have to save a map of auids to uids in the database.

  • @PitaJ is there any example of code for this ?

  • GNU/Linux Admin

    @Simos what have you tried so far?

  • @julian I've try only user.getUserDataByField function 😄 than i've discovered is limited.

  • GNU/Linux Admin

    Yes, you can use that method. You just need to create a plugin hook listener to the whitelist hook @baris mentioned, so you can add the remoteId to the whitelisted fields.

  • @julian so i need to make an hook on getUserDataByField ?

  • @julian I'm trying to understand how make an hook for getUserDataByField, but pheraps i'm too noob, i write what i've done :

    i've added the user create hook in plugin.json :

    { "hook": "filter:user.create", "method": "filterUserCreate" },

    than i've added the function to the library lo listen for 'filter:user.create' :

    plugin.filterUserCreate = function (data, callback) {
        data.user.auid = data.data.auid;
        callback(null, data);

    I've added the whitelist hook :

    { "hook": "filter:user.whitelistFields", "method": "whitelistFields" },

    than i've added the function to the library to listen for 'filter:user.whitelistFields' :

    plugin.whitelistFields = function(data, callback) {
    	callback(null, data);

    At this point i've checked and everythings work, on user create i've also the 'auid' fields with relative value, now i need a function to get user data knowing the remote id field 'auid', i've checked in controllers/user.js and i've found 'getUserDataByField' function wich should help me for my pourpose, but it's limited to uid, username and email.
    I've begin adding the hook for getUserDataByField function in plugin.json :

    { "hook": "filter:user.getUserDataByField", "method": "getUserDataByField" }

    than i've begin to adding the filter listener in the library :

    plugin.getUserDataByField = function (callerUid, field, fieldValue, callback) {
        if (field === 'auid') {
            user.getUidByAUid(fieldValue, next);

    Than i've loose my self 😕

Suggested Topics

| |