Merge branch 'fixBcrypt' into 'main'
Fix bcrypt See merge request v3/service/auth!52
This commit is contained in:
commit
72f2333508
|
@ -11,5 +11,5 @@ MESSAGE_BROKER_URI=amqp://v3-broker:5672
|
||||||
MESSAGE_BROKER_EXCHANGE=mobicoop
|
MESSAGE_BROKER_EXCHANGE=mobicoop
|
||||||
|
|
||||||
# OPA
|
# OPA
|
||||||
OPA_IMAGE=openpolicyagent/opa:0.54.0
|
OPA_IMAGE=openpolicyagent/opa:0.57.0
|
||||||
OPA_URL=http://v3-auth-opa:8181/v1/data/
|
OPA_URL=http://v3-auth-opa:8181/v1/data/
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@mobicoop/auth",
|
"name": "@mobicoop/auth",
|
||||||
"version": "0.6.0",
|
"version": "0.6.1",
|
||||||
"description": "Mobicoop V3 Auth Service",
|
"description": "Mobicoop V3 Auth Service",
|
||||||
"author": "sbriat",
|
"author": "sbriat",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
"@nestjs/terminus": "^10.1.1",
|
"@nestjs/terminus": "^10.1.1",
|
||||||
"@prisma/client": "^5.4.2",
|
"@prisma/client": "^5.4.2",
|
||||||
"axios": "^1.5.1",
|
"axios": "^1.5.1",
|
||||||
"bcrypt": "^5.1.1",
|
"bcrypt": "5.1.0",
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
"class-validator": "^0.14.0",
|
"class-validator": "^0.14.0",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
|
|
|
@ -31,12 +31,14 @@ export class AuthenticationMapper
|
||||||
const record: AuthenticationWriteModel = {
|
const record: AuthenticationWriteModel = {
|
||||||
uuid: copy.id,
|
uuid: copy.id,
|
||||||
password: copy.password,
|
password: copy.password,
|
||||||
usernames: {
|
usernames: copy.usernames
|
||||||
|
? {
|
||||||
create: copy.usernames.map((username: UsernameProps) => ({
|
create: copy.usernames.map((username: UsernameProps) => ({
|
||||||
username: username.name,
|
username: username.name,
|
||||||
type: username.type,
|
type: username.type,
|
||||||
})),
|
})),
|
||||||
},
|
}
|
||||||
|
: undefined,
|
||||||
};
|
};
|
||||||
return record;
|
return record;
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
AuthenticationAlreadyExistsException,
|
AuthenticationAlreadyExistsException,
|
||||||
UsernameAlreadyExistsException,
|
UsernameAlreadyExistsException,
|
||||||
} from '@modules/authentication/core/domain/authentication.errors';
|
} from '@modules/authentication/core/domain/authentication.errors';
|
||||||
import { Username } from '../../types/username';
|
|
||||||
|
|
||||||
@CommandHandler(CreateAuthenticationCommand)
|
@CommandHandler(CreateAuthenticationCommand)
|
||||||
export class CreateAuthenticationService implements ICommandHandler {
|
export class CreateAuthenticationService implements ICommandHandler {
|
||||||
|
@ -27,11 +26,7 @@ export class CreateAuthenticationService implements ICommandHandler {
|
||||||
await AuthenticationEntity.create({
|
await AuthenticationEntity.create({
|
||||||
userId: command.userId,
|
userId: command.userId,
|
||||||
password: command.password,
|
password: command.password,
|
||||||
usernames: command.usernames.map((username: Username) => ({
|
usernames: command.usernames,
|
||||||
name: username.name,
|
|
||||||
type: username.type,
|
|
||||||
userId: command.userId,
|
|
||||||
})),
|
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await this.authenticationRepository.insert(authentication);
|
await this.authenticationRepository.insert(authentication);
|
||||||
|
|
|
@ -23,7 +23,7 @@ export type AuthenticationReadModel = AuthenticationBaseModel & {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AuthenticationWriteModel = AuthenticationBaseModel & {
|
export type AuthenticationWriteModel = AuthenticationBaseModel & {
|
||||||
usernames: {
|
usernames?: {
|
||||||
create: UsernameModel[];
|
create: UsernameModel[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Type } from '@modules/authentication/core/domain/username.types';
|
||||||
import {
|
import {
|
||||||
AuthenticationReadModel,
|
AuthenticationReadModel,
|
||||||
AuthenticationWriteModel,
|
AuthenticationWriteModel,
|
||||||
|
UsernameModel,
|
||||||
} from '@modules/authentication/infrastructure/authentication.repository';
|
} from '@modules/authentication/infrastructure/authentication.repository';
|
||||||
import { AuthenticationResponseDto } from '@modules/authentication/interface/dtos/authentication.response.dto';
|
import { AuthenticationResponseDto } from '@modules/authentication/interface/dtos/authentication.response.dto';
|
||||||
import { Test } from '@nestjs/testing';
|
import { Test } from '@nestjs/testing';
|
||||||
|
@ -63,8 +64,12 @@ describe('Authentication Mapper', () => {
|
||||||
it('should map domain entity to persistence data', async () => {
|
it('should map domain entity to persistence data', async () => {
|
||||||
const mapped: AuthenticationWriteModel =
|
const mapped: AuthenticationWriteModel =
|
||||||
authenticationMapper.toPersistence(authenticationEntity);
|
authenticationMapper.toPersistence(authenticationEntity);
|
||||||
expect(mapped.usernames.create[0].username).toBe('john.doe@email.com');
|
expect(
|
||||||
expect(mapped.usernames.create[1].username).toBe('+33611223344');
|
(mapped.usernames as { create: UsernameModel[] }).create[0].username,
|
||||||
|
).toBe('john.doe@email.com');
|
||||||
|
expect(
|
||||||
|
(mapped.usernames as { create: UsernameModel[] }).create[1].username,
|
||||||
|
).toBe('+33611223344');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should map persisted data to domain entity', async () => {
|
it('should map persisted data to domain entity', async () => {
|
||||||
|
|
Loading…
Reference in New Issue