diff --git a/src/modules/authentication/interface/message-handlers/user-deleted.message-handler.ts b/src/modules/authentication/interface/message-handlers/user-deleted.message-handler.ts index ccbe54d..307d304 100644 --- a/src/modules/authentication/interface/message-handlers/user-deleted.message-handler.ts +++ b/src/modules/authentication/interface/message-handlers/user-deleted.message-handler.ts @@ -13,10 +13,10 @@ export class UserDeletedMessageHandler { public async userDeleted(message: string) { const deletedUser = JSON.parse(message); try { - if (!deletedUser.hasOwnProperty('userId')) throw new Error(); + if (!deletedUser.hasOwnProperty('id')) throw new Error(); await this.commandBus.execute( new DeleteAuthenticationCommand({ - userId: deletedUser.userId, + userId: deletedUser.id, }), ); } catch (e: any) {} diff --git a/src/modules/authentication/interface/message-handlers/user-updated.message-handler.ts b/src/modules/authentication/interface/message-handlers/user-updated.message-handler.ts index 55a280b..0e34970 100644 --- a/src/modules/authentication/interface/message-handlers/user-updated.message-handler.ts +++ b/src/modules/authentication/interface/message-handlers/user-updated.message-handler.ts @@ -14,11 +14,11 @@ export class UserUpdatedMessageHandler { public async userUpdated(message: string) { const updatedUser = JSON.parse(message); try { - if (!updatedUser.hasOwnProperty('userId')) throw new Error(); + if (!updatedUser.hasOwnProperty('id')) throw new Error(); if (updatedUser.hasOwnProperty('email') && updatedUser.email) { await this.commandBus.execute( new UpdateUsernameCommand({ - userId: updatedUser.userId, + userId: updatedUser.id, username: { name: updatedUser.email, type: Type.EMAIL, @@ -29,7 +29,7 @@ export class UserUpdatedMessageHandler { if (updatedUser.hasOwnProperty('phone') && updatedUser.phone) { await this.commandBus.execute( new UpdateUsernameCommand({ - userId: updatedUser.userId, + userId: updatedUser.if, username: { name: updatedUser.phone, type: Type.PHONE, diff --git a/src/modules/authentication/tests/unit/interface/user-deleted.message-handler.spec.ts b/src/modules/authentication/tests/unit/interface/user-deleted.message-handler.spec.ts index 17e8c1d..5e87302 100644 --- a/src/modules/authentication/tests/unit/interface/user-deleted.message-handler.spec.ts +++ b/src/modules/authentication/tests/unit/interface/user-deleted.message-handler.spec.ts @@ -2,10 +2,10 @@ import { UserDeletedMessageHandler } from '@modules/authentication/interface/mes import { CommandBus } from '@nestjs/cqrs'; import { Test, TestingModule } from '@nestjs/testing'; -const userDeletedMessage = '{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca"}'; +const userDeletedMessage = '{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca"}'; const userIdNotProvidedDeletedMessage = - '{"user":"2436d413-b7c7-429e-9792-b78edc17b300"}'; + '{"userId":"2436d413-b7c7-429e-9792-b78edc17b300"}'; const mockCommandBus = { execute: jest.fn().mockImplementationOnce(() => 'john.doe@email.com'), diff --git a/src/modules/authentication/tests/unit/interface/user-updated.message-handler.spec.ts b/src/modules/authentication/tests/unit/interface/user-updated.message-handler.spec.ts index 6b18907..f34ae7b 100644 --- a/src/modules/authentication/tests/unit/interface/user-updated.message-handler.spec.ts +++ b/src/modules/authentication/tests/unit/interface/user-updated.message-handler.spec.ts @@ -3,16 +3,16 @@ import { CommandBus } from '@nestjs/cqrs'; import { Test, TestingModule } from '@nestjs/testing'; const userEmailUpdatedMessage = - '{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca","email":"new-john.doe@email.com"}'; + '{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca","email":"new-john.doe@email.com"}'; const userPhoneUpdatedMessage = - '{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca","phone":"+33611224455"}'; + '{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca","phone":"+33611224455"}'; const userBirthDateUpdatedMessage = - '{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca","birthDate":"1976-10-23"}'; + '{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca","birthDate":"1976-10-23"}'; const userIdNotProvidedUpdatedMessage = - '{"user":"2436d413-b7c7-429e-9792-b78edc17b300","email":"new-john.doe@email.com"}'; + '{"userId":"2436d413-b7c7-429e-9792-b78edc17b300","email":"new-john.doe@email.com"}'; const mockCommandBus = { execute: jest