diff --git a/src/users/users.service.spec.ts b/src/users/users.service.spec.ts index 668890e124e3745b6d940e463ca4aba98fc105f0..558492b5df107e51b0380755c3ab14a8f29b46af 100644 --- a/src/users/users.service.spec.ts +++ b/src/users/users.service.spec.ts @@ -80,7 +80,7 @@ describe('UsersService', () => { it('User should not be created, weak password', async () => { const result = new HttpException( - 'Weak password, it must contain ne lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer', + 'Weak password, it must contain one lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer', HttpStatus.UNPROCESSABLE_ENTITY ); const userDto: CreateUserDto = { @@ -253,7 +253,7 @@ describe('UsersService', () => { it('should not validate new password: weak password', async () => { const result = new HttpException( - 'Weak password, it must contain ne lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer', + 'Weak password, it must contain one lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer', HttpStatus.UNPROCESSABLE_ENTITY ); jest.spyOn(service, 'validatePasswordResetToken').mockImplementation(async (): Promise<HttpException> => result); diff --git a/src/users/users.service.ts b/src/users/users.service.ts index 354f5cee6acc07ca964a7c6b240a49519349dac0..d02c4b13ed4f7576f57ab17f1592492a455493eb 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -28,7 +28,7 @@ export class UsersService { } if (!this.isStrongPassword(createUserDto.password)) { throw new HttpException( - 'Weak password, it must contain ne lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer', + 'Weak password, it must contain one lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer', HttpStatus.UNPROCESSABLE_ENTITY ); } @@ -57,7 +57,9 @@ export class UsersService { * @param password string */ private isStrongPassword(password: string): boolean { - const strongRegex = new RegExp('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})'); //NOSONAR + const strongRegex = new RegExp( + '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[*.! @#$%^&(){}[]:;<>,?/\\~_+-=|])(?=.{8,})' + ); //NOSONAR return strongRegex.test(password); } @@ -237,7 +239,7 @@ export class UsersService { } if (!this.isStrongPassword(newPassword)) { throw new HttpException( - 'Weak password, it must contain ne lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer', + 'Weak password, it must contain one lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer', HttpStatus.UNPROCESSABLE_ENTITY ); } @@ -281,7 +283,7 @@ export class UsersService { if (user) { if (!this.isStrongPassword(password)) { throw new HttpException( - 'Weak password, it must contain ne lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer', + 'Weak password, it must contain one lowercase alphabetical character, one uppercase alphabetical character, one numeric character, one special character and be eight characters or longer', HttpStatus.UNPROCESSABLE_ENTITY ); } diff --git a/test/mock/services/categoriesOthers.mock.service.ts b/test/mock/services/categoriesOthers.mock.service.ts index 7b952c68df7b252f1ef99110583fdba025724bce..70e0b3fa9de9d47913d317436e2d0d1dd7e1b92b 100644 --- a/test/mock/services/categoriesOthers.mock.service.ts +++ b/test/mock/services/categoriesOthers.mock.service.ts @@ -18,8 +18,8 @@ export class CategoriesOthersServiceMock { { modules: [ { - id: "Personnes en situation d'illetrisme", - text: "Personnes en situation d'illetrisme", + id: "Personnes en situation d'illettrisme", + text: "Personnes en situation d'illettrisme", }, { id: 'Langue étrangère (anglais)',