diff --git a/packages/core/src/libraries/user.ts b/packages/core/src/libraries/user.ts index e1db461cb..bbeed25b8 100644 --- a/packages/core/src/libraries/user.ts +++ b/packages/core/src/libraries/user.ts @@ -33,14 +33,17 @@ export const encryptUserPassword = async ( }; export const verifyUserPassword = async (user: Nullable, password: string): Promise => { - assertThat(user, 'session.invalid_credentials'); + assertThat(user, new RequestError({ code: 'session.invalid_credentials', status: 401 })); const { passwordEncrypted, passwordEncryptionMethod } = user; - assertThat(passwordEncrypted && passwordEncryptionMethod, 'session.invalid_credentials'); + assertThat( + passwordEncrypted && passwordEncryptionMethod, + new RequestError({ code: 'session.invalid_credentials', status: 401 }) + ); const result = await argon2Verify({ password, hash: passwordEncrypted }); - assertThat(result, 'session.invalid_credentials'); + assertThat(result, new RequestError({ code: 'session.invalid_credentials', status: 401 })); return user; };