diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dcccc2a..ee9d5c30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.8 (October 21st, 2023) + +- delete tokens from redis on user deletion + ## 1.3.7 (October 14th, 2023) - added null condition for comparison of nested attributes diff --git a/package-lock.json b/package-lock.json index efd3ed6f..495ec56d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@restorecommerce/identity-srv", - "version": "1.3.7", + "version": "1.3.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@restorecommerce/identity-srv", - "version": "1.3.7", + "version": "1.3.8", "license": "MIT", "dependencies": { "@restorecommerce/acs-client": "^1.1.20", diff --git a/package.json b/package.json index 47e5d8d8..6ab3fbf3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@restorecommerce/identity-srv", - "version": "1.3.7", + "version": "1.3.8", "description": "Restorecommerce identity service", "main": "lib/start.js", "author": "n-fuse GmbH", diff --git a/src/service.ts b/src/service.ts index 1f98ebc6..33f24f89 100644 --- a/src/service.ts +++ b/src/service.ts @@ -1896,7 +1896,7 @@ export class UserService extends ServiceBase impleme } private nestedAttributesEqual(dbAttributes, userAttributes) { - if(!userAttributes) { + if (!userAttributes) { return true; } if (dbAttributes?.length > 0 && userAttributes?.length > 0) { @@ -2245,6 +2245,28 @@ export class UserService extends ServiceBase impleme ids: userIDs }), context); logger.info('Users deleted:', userIDs); + if (userIDs.length > 0) { + const filters = [{ + filters: [{ + field: 'id', + operation: Filter_Operation.in, + value: JSON.stringify(userIDs), + type: FilterValueType.ARRAY + }] + }]; + let userData = await super.read({ + filters, + } as any, {}); + if (userData?.items?.length > 0) { + userData?.items?.forEach((user) => { + user?.payload?.tokens?.forEach(async (tokenObj) => { + if(tokenObj?.token) { + await this.tokenRedisClient.del(tokenObj.token); + } + }); + }); + } + } return deleteStatusArr; } }