Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/node/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,7 @@ export const generatePassword = async (length = 24): Promise<string> => {
* Used to hash the password.
*/
export const hash = async (password: string): Promise<string> => {
try {
return await argon2.hash(password)
} catch (error: any) {
logger.error(error)
return ""
}
Comment on lines -160 to -165
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✍🏼 as discussed with @code-asher, this will only throw if you throw in something other than string (like number). Since TS will prevent that, we don't need the try/catch block.

return await argon2.hash(password)
}

/**
Expand Down
4 changes: 4 additions & 0 deletions test/unit/node/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ describe("hash", () => {
const hashed = await util.hash(plainTextPassword)
expect(hashed).not.toBe(plainTextPassword)
})
it("should return a hash for an empty string", async () => {
const hashed = await util.hash("")
expect(hashed).not.toBe("")
})
})

describe("isHashMatch", () => {
Expand Down