Skip to content

Commit

Permalink
fix: return empty pwd hash and salt if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMaz committed Feb 21, 2024
1 parent ae9464c commit b282535
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions packages/nestjs-user/src/services/user-password.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b282535

Please sign in to comment.