Implement pwd check
This commit is contained in:
+10
-1
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user