Skip to content

Commit a8069a5

Browse files
committed
fixup
1 parent ed43c47 commit a8069a5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/node/util.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as path from "path"
99
import * as util from "util"
1010
import xdgBasedir from "xdg-basedir"
1111
import safeCompare from "safe-compare"
12+
import { logger } from "@coder/logger"
1213

1314
export interface Paths {
1415
data: string
@@ -121,14 +122,24 @@ export const generatePassword = async (length = 24): Promise<string> => {
121122
* Used to hash the password.
122123
*/
123124
export const hash = async (password: string): Promise<string> => {
124-
return await argon2.hash(password)
125+
try {
126+
return await argon2.hash(password)
127+
} catch (error) {
128+
logger.error(error)
129+
return ""
130+
}
125131
}
126132

127133
/**
128134
* Used to verify if the password matches the hash
129135
*/
130136
export const isHashMatch = async (password: string, hash: string) => {
131-
return await argon2.verify(hash, password)
137+
try {
138+
return await argon2.verify(hash, password)
139+
} catch (error) {
140+
logger.error(error)
141+
return false
142+
}
132143
}
133144

134145
/**

0 commit comments

Comments
 (0)