Skip to content

Commit 9c56bd1

Browse files
committed
removing bcrypt.compare from try/catch
1 parent d7419b6 commit 9c56bd1

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

src/application/use-cases/auth/sign-in.use-case.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,10 @@ export const signInUseCase =
3030
throw new AuthenticationError('User does not exist');
3131
}
3232

33-
let validPassword = false;
34-
try {
35-
validPassword = await instrumentationService.startSpan(
36-
{ name: 'verify password hash', op: 'function' },
37-
() => compare(input.password, existingUser.password_hash)
38-
);
39-
} catch (err) {
40-
console.error('password hash comparison error', err);
41-
}
33+
const validPassword = await instrumentationService.startSpan(
34+
{ name: 'verify password hash', op: 'function' },
35+
() => compare(input.password, existingUser.password_hash)
36+
);
4237

4338
if (!validPassword) {
4439
throw new AuthenticationError('Incorrect username or password');

src/application/use-cases/auth/sign-up.use-case.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,10 @@ export const signUpUseCase =
3535
throw new AuthenticationError('Username taken');
3636
}
3737

38-
let passwordHash = '';
39-
try {
40-
passwordHash = await instrumentationService.startSpan(
41-
{ name: 'hash password', op: 'function' },
42-
() => hash(input.password, PASSWORD_SALT_ROUNDS)
43-
);
44-
} catch (err) {
45-
console.error('password hash error', err);
46-
throw new AuthenticationError('Failed to hash password', {
47-
cause: err,
48-
});
49-
}
38+
const passwordHash = await instrumentationService.startSpan(
39+
{ name: 'hash password', op: 'function' },
40+
() => hash(input.password, PASSWORD_SALT_ROUNDS)
41+
);
5042

5143
const userId = authenticationService.generateUserId();
5244

0 commit comments

Comments
 (0)