kuzzle 2.16.9 → 2.16.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -130,7 +130,7 @@ class TokenRepository extends Repository {
130
130
  global.kuzzle.onAsk(
131
131
  'core:security:token:verify',
132
132
  hash => this.verifyToken(hash));
133
-
133
+
134
134
  }
135
135
 
136
136
  /**
@@ -255,8 +255,8 @@ class TokenRepository extends Repository {
255
255
  * @returns {Promise}
256
256
  */
257
257
  async persistForUser (encodedToken, userId, ttl) {
258
- const redisTTL = ttl !== -1 ? ttl : 0;
259
- const expiresAt = ttl !== -1 ? Date.now() + ttl : -1;
258
+ const redisTTL = ttl === -1 ? 0 : ttl;
259
+ const expiresAt = ttl === -1 ? -1 : Date.now() + ttl;
260
260
  const token = new Token({
261
261
  _id: `${userId}#${encodedToken}`,
262
262
  expiresAt,
@@ -396,7 +396,7 @@ class TokenRepository extends Repository {
396
396
  if (keepApiKeys && cacheToken.type === 'apiKey') {
397
397
  return;
398
398
  }
399
-
399
+
400
400
  await this.expire(cacheToken);
401
401
  }
402
402
  });
@@ -428,13 +428,10 @@ class TokenRepository extends Repository {
428
428
  debug('Loading API keys into Redis');
429
429
 
430
430
  const promises = [];
431
- const createToken = async ({ token, userId, ttl }) => {
432
- return await this.persistForUser(token, userId, ttl);
433
- };
434
431
 
435
- await ApiKey.batchExecute({ match_all: {} }, apiKeys => {
436
- for (const apiKey of apiKeys) {
437
- promises.push(createToken(apiKey));
432
+ await ApiKey.batchExecute({ match_all: {} }, documents => {
433
+ for (const { _source } of documents) {
434
+ promises.push(this.persistForUser(_source.token, _source.userId, _source.ttl));
438
435
  }
439
436
  });
440
437
 
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kuzzle",
3
- "version": "2.16.9",
3
+ "version": "2.16.10",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kuzzle",
3
3
  "author": "The Kuzzle Team <support@kuzzle.io>",
4
- "version": "2.16.9",
4
+ "version": "2.16.10",
5
5
  "description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
6
6
  "bin": {
7
7
  "kuzzle": "bin/start-kuzzle-server"