Merge branch 'changeUserIntegrationEvents' into 'main'

Change user integration events

See merge request v3/service/auth!48
This commit is contained in:
Sylvain Briat 2023-07-24 14:08:15 +00:00
commit 0096b8a4c8
6 changed files with 47 additions and 18 deletions

39
package-lock.json generated
View File

@ -1,18 +1,18 @@
{
"name": "@mobicoop/auth",
"version": "0.4.0",
"version": "0.5.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@mobicoop/auth",
"version": "0.4.0",
"version": "0.5.0",
"license": "AGPL",
"dependencies": {
"@golevelup/nestjs-rabbitmq": "^3.4.0",
"@grpc/grpc-js": "^1.8.0",
"@grpc/proto-loader": "^0.7.4",
"@mobicoop/ddd-library": "^0.3.0",
"@mobicoop/ddd-library": "^1.0.0",
"@mobicoop/health-module": "^2.0.0",
"@mobicoop/message-broker-module": "^1.2.0",
"@nestjs/axios": "^1.0.1",
@ -1370,8 +1370,9 @@
}
},
"node_modules/@mobicoop/ddd-library": {
"version": "0.3.0",
"license": "AGPL",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@mobicoop/ddd-library/-/ddd-library-1.0.0.tgz",
"integrity": "sha512-uOF2n2VqgfVP4QldEPGMuR3VPn0U5+XXQw5CK1E/9IHXIgiqdmAnKHX5qUpcr29mKbU5QvQbBuIyMeQqCFVu+w==",
"dependencies": {
"@nestjs/event-emitter": "^1.4.2",
"@nestjs/microservices": "^9.4.0",
@ -1413,6 +1414,21 @@
"@nestjs/common": "^9.4.2"
}
},
"node_modules/@mobicoop/health-module/node_modules/@mobicoop/ddd-library": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@mobicoop/ddd-library/-/ddd-library-0.3.0.tgz",
"integrity": "sha512-MoUDqlrDmJkumCFSyW9FY2DLbguT4rytFrmBt9tVNCr2Es6nlz4Ml3HVBwJTZrlJFU79XmiUQ5WAO0MHJt+nAg==",
"dependencies": {
"@nestjs/event-emitter": "^1.4.2",
"@nestjs/microservices": "^9.4.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"uuid": "^9.0.0"
},
"peerDependencies": {
"@nestjs/common": "^9.4.2"
}
},
"node_modules/@mobicoop/health-module/node_modules/@nestjs/axios": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.0.tgz",
@ -1424,6 +1440,19 @@
"rxjs": "^6.0.0 || ^7.0.0"
}
},
"node_modules/@mobicoop/health-module/node_modules/@nestjs/event-emitter": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/@nestjs/event-emitter/-/event-emitter-1.4.2.tgz",
"integrity": "sha512-5mskPMS4KVH6LghC+NynfdmGiMCOOv9CdgVpuWGipLrJECv5KWc7vaW5o/9BYrcqPkN7Ted6CJ+O4AfsTiRlgw==",
"dependencies": {
"eventemitter2": "6.4.9"
},
"peerDependencies": {
"@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.0.0",
"@nestjs/core": "^7.0.0 || ^8.0.0 || ^9.0.0",
"reflect-metadata": "^0.1.12"
}
},
"node_modules/@mobicoop/message-broker-module": {
"version": "1.2.0",
"license": "AGPL",

View File

@ -1,6 +1,6 @@
{
"name": "@mobicoop/auth",
"version": "0.4.0",
"version": "0.5.0",
"description": "Mobicoop V3 Auth Service",
"author": "sbriat",
"private": true,
@ -33,7 +33,7 @@
"@golevelup/nestjs-rabbitmq": "^3.4.0",
"@grpc/grpc-js": "^1.8.0",
"@grpc/proto-loader": "^0.7.4",
"@mobicoop/ddd-library": "^0.3.0",
"@mobicoop/ddd-library": "^1.0.0",
"@mobicoop/health-module": "^2.0.0",
"@mobicoop/message-broker-module": "^1.2.0",
"@nestjs/axios": "^1.0.1",

View File

@ -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) {}

View File

@ -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,

View File

@ -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'),

View File

@ -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