SOLVED Why new accounts created by api doesn't work with nodebb-plugin-session-sharing


  • Hello,
    I created some accounts with the api/v3, but those accounts can't log in by email on the forum, and consequently can't log in with session sharing plugin.

    I searched a long time, because this used to work on nodebb v1.15.
    But on v1.18, some db objects are only set after the call of confirmByUid function :

    ['email:uid', uid, currentEmail.toLowerCase()],
    ['email:sorted', 0, `${currentEmail.toLowerCase()}:${uid}`],
    [`user:${uid}:emails`, Date.now(), `${currentEmail}:${Date.now()}`]
    

    So you have to confirm each account before the plugin "session sharing" works with them.

    To resolve this, i made a custom plugin and used the "confirmByUid" function :

    library.js :

    const Users = require.main.require('./src/user')
    var Plugin = {
    	onCreateUser: function (postData) {
    		const { user } = postData;
    		Users.email.confirmByUid(user.uid);
    		Topics.markAllRead(user.uid);
    	}
    }
    

    plugin.json :

    "library": "./library.js",
    "hooks": [
    	{ "hook": "action:user.create", "method": "onCreateUser" },
    ]
    

    I hope this can help ;).

  • Topic has been marked as solved  F Fred 

Suggested Topics

| |