From b2825353ddb3bd21f83832cc47f9f538a3eee0ec Mon Sep 17 00:00:00 2001 From: Marshall Sorenson Date: Wed, 21 Feb 2024 16:20:53 -0500 Subject: [PATCH] fix: return empty pwd hash and salt if not exists --- .../src/services/user-password.service.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/nestjs-user/src/services/user-password.service.ts b/packages/nestjs-user/src/services/user-password.service.ts index e650ea12d..2d12855f3 100644 --- a/packages/nestjs-user/src/services/user-password.service.ts +++ b/packages/nestjs-user/src/services/user-password.service.ts @@ -90,18 +90,12 @@ export class UserPasswordService implements UserPasswordServiceInterface { // break out the stored password const { passwordHash, passwordSalt } = user; - // type guards - if ( - typeof passwordHash === 'string' && - typeof passwordSalt === 'string' - ) { - // return the user with asserted storage types - return { ...user, passwordHash, passwordSalt }; - } else { - throw new UserException( - 'User object is missing some or all password storage properties', - ); - } + // return the user with asserted storage types + return { + ...user, + passwordHash: typeof passwordHash === 'string' ? passwordHash : '', + passwordSalt: typeof passwordSalt === 'string' ? passwordSalt : '', + }; } // throw an exception by default