@baris: MAXON with his PluginCafé discussion board for Cinema 4D plugins external developers.
Cheers, KK
@baris: MAXON with his PluginCafé discussion board for Cinema 4D plugins external developers.
Cheers, KK
Hi community first and foremost thank for your valuable support.
I need to retrieve custom data I've written to mongoDB and I'd like them to be returned as JSON string via a custom WriteAPI-enabled route.
A few notes to give a better context:
I'm currently on Ubuntu 18 / nodebb 1.16.2 / Mongo DB 4.0.22 / npm 6.14.10
I've already read
I've looked at
and, in the end, I've created an API Access token bound to the forum administrator which works nicely to read and write in the forum (e.g. retrieving the topics or creating a new one)
Issues:
Advanced -> Hooks
but:
[plugins/friends] Write API integration enabled, routes added.
as specified here?<url/to/nodebb>/api/v3/friends/:uid
, <url/to/nodebb>/api/friends/:uid
, <url/to/nodebb>/friends/:uid
, <url/to/nodebb>api/v3/plugins/friends/:uid
- worked for me)'use strict';
(function(routes) {
routes.initWriteRoutes = function(data, callback) {
data.router.get('/route1', data.apiMiddleware.requireUser, data.apiMiddleware.requireAdmin, middleware.verifyUserExists, function(req, res) {
console.log("/route1 reached via get");
res.sendStatus(200);
});
data.router.post('/route2', data.apiMiddleware.requireUser, middleware.verifyUserExists, function(req, res) {
console.log("/route2 reached via post");
res.sendStatus(200);
});
data.router.delete('/route3', data.apiMiddleware.requireUser, middleware.verifyUserExists, function(req, res) {
console.log("/route3 reached via delete");
res.sendStatus(200);
});
console.log('[plugins/test] Write API integration enabled, routes added.');
callback(null, data);
};
}(module.exports));
{
"library": "./library.js",
"hooks": [
{ "hook": "filter:plugin.write-api.routes", "method": "initWriteRoutes" }
]
}
info: [api] Adding 0 route(s) to 'api/v3/plugins'
with 0 new routes? Shouldn't it include at least the new routes coming with this plugin?I apologise for the length of this post, but I think this might help you to steer me in the right direction.
Best, Riccardo
Hi community,
is it possible to specify multiple tags in the Tags page or to even define boolean expression with (AND, OR, NOT)?
Best, KK
@julian that's awesome thanks a lot!
@baris thanks a lot! You brought me into the right direction.
I've queried the DB for db.getCollection('objects').find({"_key":{$regex:'maxonIDId:uid'}})
and deleted the found object. This just made the trick and disconnected the retuned OAuthID from the actual nodebb uid.
Thanks a lot for looking at the thread and also checking the my code!
Really appreciated you're awesome guys!
Looking at one of the sessions object I've spotted
"registration\":{\"returnTo\":\"/\",\"uid\":8},\"passport\":{\"user\":8}}"
which seems like it's referring to the same uid that my user had before getting deleted. Looks like that re-registering myself with the same account tries to use the same uid.
Does it make any sense to you gurus?
Cheers, R
@pitaj already done and sadly no better results
@baris said in session mismatch error after deleting user:
Also can you try with this change https://github.com/NodeBB/NodeBB/commit/beb14273876406b69bb202ab2805926862e27879
@baris change done but no good result
config.json looks like
{
"url": "https://aaa.bbb.ccc.ddd",
"secret": "xxxxxxxxxxxxxxxxxxxxxxx",
"database": "mongo",
"mongo": {
"uri": "mongodb://nodebb:nodebb-pass@localhost/nodebb",
"uri_long": "mongodb://nodebb:nodebb-pass@localhost/nodebb"
},
"port": "4567",
"socket.io": {
"origins": "https://aaa.bbb.ccc.ddd:*"
},
and looking in the DB I see in the sessions collections
/* 1 */
{
"_id" : "bzuVRBphBzKSUZ3Yt9VxEQUPuJoU5nKh",
"expires" : ISODate("2021-03-05T15:41:25.409Z"),
"session" : "{\"cookie\":{\"originalMaxAge\":1209600000,\"expires\":\"2021-03-05T15:41:17.902Z\",\"secure\":true,\"httpOnly\":true,\"path\":\"/\",\"sameSite\":\"Lax\"},\"returnTo\":\"/\",\"flash\":{},\"passport\":{\"user\":8}}"
}
/* 2 */
{
"_id" : "mqBJSla7h9jDaRjbdpEsCpbIaXpZxKIX",
"expires" : ISODate("2021-03-05T17:02:35.259Z"),
"session" : "{\"cookie\":{\"originalMaxAge\":1209600000,\"expires\":\"2021-03-05T17:02:34.250Z\",\"secure\":true,\"httpOnly\":true,\"path\":\"/\",\"sameSite\":\"Lax\"},\"returnTo\":\"/\",\"flash\":{},\"registration\":{\"returnTo\":\"/\",\"uid\":8},\"passport\":{\"user\":8}}"
}
I've tried already to delete anything in the sessions collection but with no better luck
To give better context consider that my user is attempting to authenticate using this OAuth2 plugin I've developed and nodebb get stuck as soon as I'm authenticated against my identity provider and I'm going to set my privacy settings
Thanks for any help
@baris said in session mismatch error after deleting user:
app.logout()
Thanks @baris running app.logout()
just stops the pop-up to show up cause an actual logout takes place, but as soon as I attempt to login the pop-up starts again and again
Hi guys,
I need to get out of a trouble I really can't figure out how to.
This morning in order to get my forum cleaned up for an internal testing phase, I have deleted all the users (and their posts) from via the administration panel. Everything went well and the forum got cleaned up except for the admin account.
I'm now trying to re-register myself with my previous credentials I used as standard user but after the initial success of the registration I've nodebb constantly showing up this "Session Mismatch" pop-up.
I've trie with cleaning the browser cache, I've tried with a different browser, I've tried to clean-up also the sessions
collections in the Mongo DB but I still get the pop-up.
Do you have an idea how I can get it fixed? Or the sole option I have is to restore the database before the users clean-up phase?
Thanks, Riccardo
@julian that's awesome thanks a lot!
Thanks a lot @PitaJ and @julian, changing the hook worked.
Moving to api/v3 looks like I can't use what @julian mentioned
It passes in router, apiMiddleware, middleware, and errorHandler, so given that you can style your own routes like I do in the write api, e.g.:
var addRoutes = function(data, callback) { data.router.get('/awesome', apiMiddleware.requireUser, function(req, res) { console.log('lorem ipsum!'); res.sendStatus(200); }); callback(null, data); });
In the above example, I used the requireUser middleware, which, provided by the write-api, means you have to pass in an user/master token just like the other routes. It also sets req.user.uid for you to use.
How can I check that the bearer Token coming with the req.header is valid and corresponds to a certain user to which the bearer token is bound to?
Any snippet to look at?
Thanks, Riccardo
Hi community first and foremost thank for your valuable support.
I need to retrieve custom data I've written to mongoDB and I'd like them to be returned as JSON string via a custom WriteAPI-enabled route.
A few notes to give a better context:
I'm currently on Ubuntu 18 / nodebb 1.16.2 / Mongo DB 4.0.22 / npm 6.14.10
I've already read
I've looked at
and, in the end, I've created an API Access token bound to the forum administrator which works nicely to read and write in the forum (e.g. retrieving the topics or creating a new one)
Issues:
Advanced -> Hooks
but:
[plugins/friends] Write API integration enabled, routes added.
as specified here?<url/to/nodebb>/api/v3/friends/:uid
, <url/to/nodebb>/api/friends/:uid
, <url/to/nodebb>/friends/:uid
, <url/to/nodebb>api/v3/plugins/friends/:uid
- worked for me)'use strict';
(function(routes) {
routes.initWriteRoutes = function(data, callback) {
data.router.get('/route1', data.apiMiddleware.requireUser, data.apiMiddleware.requireAdmin, middleware.verifyUserExists, function(req, res) {
console.log("/route1 reached via get");
res.sendStatus(200);
});
data.router.post('/route2', data.apiMiddleware.requireUser, middleware.verifyUserExists, function(req, res) {
console.log("/route2 reached via post");
res.sendStatus(200);
});
data.router.delete('/route3', data.apiMiddleware.requireUser, middleware.verifyUserExists, function(req, res) {
console.log("/route3 reached via delete");
res.sendStatus(200);
});
console.log('[plugins/test] Write API integration enabled, routes added.');
callback(null, data);
};
}(module.exports));
{
"library": "./library.js",
"hooks": [
{ "hook": "filter:plugin.write-api.routes", "method": "initWriteRoutes" }
]
}
info: [api] Adding 0 route(s) to 'api/v3/plugins'
with 0 new routes? Shouldn't it include at least the new routes coming with this plugin?I apologise for the length of this post, but I think this might help you to steer me in the right direction.
Best, Riccardo