Implement pwd check

This commit is contained in:
2024-05-21 16:09:14 +02:00
parent dc56f6fd31
commit fe88dcd091
+10 -1
View File
@@ -1,7 +1,16 @@
import logger from 'log'
const log = logger('crypto-server:pwd')
export function hash(pwd: string) : Promise<string> {
log.debug('hash password')
return Bun.password.hash(pwd)
}
export async function verify(pwd: string, hash: string) : Promise<boolean> {
return Bun.password.verify(pwd, hash).catch(() => false)
log.debug("verify password's hash")
return Bun.password.verify(pwd, hash).catch(e => {
log.warn('Password verification failed')
log.debug(`Error : ${e}`)
return false
})
}