All the API token erased from the admin page
-
@nullpointer how are you creating these tokens? What database are you using? Are the tokens still in the database when you look at the keys
settings:core.api:sorted-list:tokens:0
. Each sorted-list item is stored as a separate document so it shouldn't hit the limit I think. -
@baris I use the existing code:
const settings = await meta.settings.get('core.api'); settings.tokens = settings.tokens || []; const newToken = { token: utils.generateUUID(), uid: req.params.uid, description: req.body.description || '', timestamp: Date.now(), }; settings.tokens.push(newToken); await meta.settings.set('core.api', settings);
@baris said in All the API token erased from the admin page:
Are the tokens still in the database when you look at the keys settings:core.api:sorted-list:tokens:0
I don't think so. The tokens is completely gone in DB. Here is the result of the db query
Here is the result using regex with prefix
^setting:core.api
-
The only way those items would be emptied is if you call
meta.settings.set
with an empty array of tokens.const settings = await meta.settings.get('core.api'); settings.tokens = []; await meta.settings.set('core.api', settings);
Maybe put a console.log inside
meta.settings.set
and see if it is being called like that. -
@baris there is only one line of code after that:
helpers.formatApiResponse(200, res, newToken);
@baris said in All the API token erased from the admin page:
Maybe put a console.log inside meta.settings.set and see if it is being called like that.
I will try to put this logging and see the behavior
-
Hello @julian, could you give me some references regarding this sorted-list library that you mention?
-
Solved after upgrading to v3.1.4
Reference: https://github.com/NodeBB/NodeBB/pull/11533/commitsThanks @julian for addressing this issue.
-
-
@nullpointer glad to hear it