Merge branch 'changeUserIntegrationEvents' into 'main'
Change user integration events See merge request v3/service/auth!48
This commit is contained in:
commit
0096b8a4c8
|
@ -1,18 +1,18 @@
|
||||||
{
|
{
|
||||||
"name": "@mobicoop/auth",
|
"name": "@mobicoop/auth",
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@mobicoop/auth",
|
"name": "@mobicoop/auth",
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"license": "AGPL",
|
"license": "AGPL",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@golevelup/nestjs-rabbitmq": "^3.4.0",
|
"@golevelup/nestjs-rabbitmq": "^3.4.0",
|
||||||
"@grpc/grpc-js": "^1.8.0",
|
"@grpc/grpc-js": "^1.8.0",
|
||||||
"@grpc/proto-loader": "^0.7.4",
|
"@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/health-module": "^2.0.0",
|
||||||
"@mobicoop/message-broker-module": "^1.2.0",
|
"@mobicoop/message-broker-module": "^1.2.0",
|
||||||
"@nestjs/axios": "^1.0.1",
|
"@nestjs/axios": "^1.0.1",
|
||||||
|
@ -1370,8 +1370,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mobicoop/ddd-library": {
|
"node_modules/@mobicoop/ddd-library": {
|
||||||
"version": "0.3.0",
|
"version": "1.0.0",
|
||||||
"license": "AGPL",
|
"resolved": "https://registry.npmjs.org/@mobicoop/ddd-library/-/ddd-library-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-uOF2n2VqgfVP4QldEPGMuR3VPn0U5+XXQw5CK1E/9IHXIgiqdmAnKHX5qUpcr29mKbU5QvQbBuIyMeQqCFVu+w==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nestjs/event-emitter": "^1.4.2",
|
"@nestjs/event-emitter": "^1.4.2",
|
||||||
"@nestjs/microservices": "^9.4.0",
|
"@nestjs/microservices": "^9.4.0",
|
||||||
|
@ -1413,6 +1414,21 @@
|
||||||
"@nestjs/common": "^9.4.2"
|
"@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": {
|
"node_modules/@mobicoop/health-module/node_modules/@nestjs/axios": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.0.tgz",
|
||||||
|
@ -1424,6 +1440,19 @@
|
||||||
"rxjs": "^6.0.0 || ^7.0.0"
|
"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": {
|
"node_modules/@mobicoop/message-broker-module": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"license": "AGPL",
|
"license": "AGPL",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@mobicoop/auth",
|
"name": "@mobicoop/auth",
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"description": "Mobicoop V3 Auth Service",
|
"description": "Mobicoop V3 Auth Service",
|
||||||
"author": "sbriat",
|
"author": "sbriat",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
"@golevelup/nestjs-rabbitmq": "^3.4.0",
|
"@golevelup/nestjs-rabbitmq": "^3.4.0",
|
||||||
"@grpc/grpc-js": "^1.8.0",
|
"@grpc/grpc-js": "^1.8.0",
|
||||||
"@grpc/proto-loader": "^0.7.4",
|
"@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/health-module": "^2.0.0",
|
||||||
"@mobicoop/message-broker-module": "^1.2.0",
|
"@mobicoop/message-broker-module": "^1.2.0",
|
||||||
"@nestjs/axios": "^1.0.1",
|
"@nestjs/axios": "^1.0.1",
|
||||||
|
|
|
@ -13,10 +13,10 @@ export class UserDeletedMessageHandler {
|
||||||
public async userDeleted(message: string) {
|
public async userDeleted(message: string) {
|
||||||
const deletedUser = JSON.parse(message);
|
const deletedUser = JSON.parse(message);
|
||||||
try {
|
try {
|
||||||
if (!deletedUser.hasOwnProperty('userId')) throw new Error();
|
if (!deletedUser.hasOwnProperty('id')) throw new Error();
|
||||||
await this.commandBus.execute(
|
await this.commandBus.execute(
|
||||||
new DeleteAuthenticationCommand({
|
new DeleteAuthenticationCommand({
|
||||||
userId: deletedUser.userId,
|
userId: deletedUser.id,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
} catch (e: any) {}
|
} catch (e: any) {}
|
||||||
|
|
|
@ -14,11 +14,11 @@ export class UserUpdatedMessageHandler {
|
||||||
public async userUpdated(message: string) {
|
public async userUpdated(message: string) {
|
||||||
const updatedUser = JSON.parse(message);
|
const updatedUser = JSON.parse(message);
|
||||||
try {
|
try {
|
||||||
if (!updatedUser.hasOwnProperty('userId')) throw new Error();
|
if (!updatedUser.hasOwnProperty('id')) throw new Error();
|
||||||
if (updatedUser.hasOwnProperty('email') && updatedUser.email) {
|
if (updatedUser.hasOwnProperty('email') && updatedUser.email) {
|
||||||
await this.commandBus.execute(
|
await this.commandBus.execute(
|
||||||
new UpdateUsernameCommand({
|
new UpdateUsernameCommand({
|
||||||
userId: updatedUser.userId,
|
userId: updatedUser.id,
|
||||||
username: {
|
username: {
|
||||||
name: updatedUser.email,
|
name: updatedUser.email,
|
||||||
type: Type.EMAIL,
|
type: Type.EMAIL,
|
||||||
|
@ -29,7 +29,7 @@ export class UserUpdatedMessageHandler {
|
||||||
if (updatedUser.hasOwnProperty('phone') && updatedUser.phone) {
|
if (updatedUser.hasOwnProperty('phone') && updatedUser.phone) {
|
||||||
await this.commandBus.execute(
|
await this.commandBus.execute(
|
||||||
new UpdateUsernameCommand({
|
new UpdateUsernameCommand({
|
||||||
userId: updatedUser.userId,
|
userId: updatedUser.if,
|
||||||
username: {
|
username: {
|
||||||
name: updatedUser.phone,
|
name: updatedUser.phone,
|
||||||
type: Type.PHONE,
|
type: Type.PHONE,
|
||||||
|
|
|
@ -2,10 +2,10 @@ import { UserDeletedMessageHandler } from '@modules/authentication/interface/mes
|
||||||
import { CommandBus } from '@nestjs/cqrs';
|
import { CommandBus } from '@nestjs/cqrs';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
|
||||||
const userDeletedMessage = '{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca"}';
|
const userDeletedMessage = '{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca"}';
|
||||||
|
|
||||||
const userIdNotProvidedDeletedMessage =
|
const userIdNotProvidedDeletedMessage =
|
||||||
'{"user":"2436d413-b7c7-429e-9792-b78edc17b300"}';
|
'{"userId":"2436d413-b7c7-429e-9792-b78edc17b300"}';
|
||||||
|
|
||||||
const mockCommandBus = {
|
const mockCommandBus = {
|
||||||
execute: jest.fn().mockImplementationOnce(() => 'john.doe@email.com'),
|
execute: jest.fn().mockImplementationOnce(() => 'john.doe@email.com'),
|
||||||
|
|
|
@ -3,16 +3,16 @@ import { CommandBus } from '@nestjs/cqrs';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
|
||||||
const userEmailUpdatedMessage =
|
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 =
|
const userPhoneUpdatedMessage =
|
||||||
'{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca","phone":"+33611224455"}';
|
'{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca","phone":"+33611224455"}';
|
||||||
|
|
||||||
const userBirthDateUpdatedMessage =
|
const userBirthDateUpdatedMessage =
|
||||||
'{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca","birthDate":"1976-10-23"}';
|
'{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca","birthDate":"1976-10-23"}';
|
||||||
|
|
||||||
const userIdNotProvidedUpdatedMessage =
|
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 = {
|
const mockCommandBus = {
|
||||||
execute: jest
|
execute: jest
|
||||||
|
|
Loading…
Reference in New Issue