I found a good way to get the user list out of mongodb. In case anyone need it:
async function doMongoDb() { const { MongoClient } = require("mongodb"); const username = encodeURIComponent("admin"); const password = encodeURIComponent("mypassword"); const clusterUrl = "localhost:27017"; const authMechanism = "DEFAULT"; const uri = `mongodb://${username}:${password}@${clusterUrl}/?authMechanism=${authMechanism}`; const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true }); try { await client.connect(); const database = client.db("nodebb"); const objects = database.collection("objects"); // get all user const query = { _key: /^user:\d+$/ }; // select fields we want to see const options = { projection: { _id: 0, username: true, _id: false, email: true, "email:confirmed": true, joindate: true, fullname: true }, }; const cursor = objects.find(query, options); if ((await cursor.count()) === 0) { console.log("No user found!"); } // iterate over the users await cursor.forEach(user => { if (user["email:confirmed"] == 1 ) { console.dir(user); } }); } finally { // make sure we close the connection await client.close(); } } // --------------------------------------------------- function init() { try { doMongoDb(); } catch(e) { console.log(e); } } // --------------------------------------------------- init();Write-enabled API (Brainstorming)
-
So I have to sync login state / user accounts.
Have a look at this plugin:
https://github.com/julianlam/nodebb-plugin-sso-oauth
You will likely have to modify it a bit to fit your solution, but it's definitely doable
-
this would be awesome. a write api would allow us to create some nice apps that are integrated with nodebb
-
Thanks @yamill -- this is definitely something that's been on our minds for the next version (not that we're thinking that far ahead yet... still 0.5.0 to be released)
-
@julian that's great news! i really love what you guys are doing with nodebb.
-
Will the planned writeable API include a login / logout (optional Register account) function?
I need something like that to call via PHP or PHP rendered code (JS if client side), because oauth isn't a useable Option.
-
yes..! this would be amazing!!
how's it coming along @julian ?
-
@agarcia17 in have a proof of concept working, though it needs to be fleshed out a bit.
I'm currently out of town (speaking at a js event in Calgary!), so I'll make it a focus of mine when I get home assuming nothing else comes up!
-
Would be nice to encode the api at user experience. like restfull.
have a 'createNewCategory' topic inside 'admTool' category, if a mod write a respod with "footbal & rugby" the api create a new category named 'footbal & rugby'.
Each category has a '/proc' topic to acces api funcion over .this category.
to chance my photo i could go to admTool/chPic topic and upload a image.if the api is themeble can pack the adm routine like moderated or not. Can be 'monarchyed', the api just accept the call of the King login.
-
Is there an update on the write API? Would be interesting to see how it's coming along.
-
Just checking to see if there was an update to this. Seems this thread has been dead-ish
-
Sort of got my own answer. though not too clear on it. Repo found here: https://github.com/NodeBB/nodebb-plugin-write-api
-
@baris Please help
nothing happened after save changes again at same screen.