From c36eb17db253e8f2dad1e95bf225632b76a4a56a Mon Sep 17 00:00:00 2001 From: Alex Ivanov Date: Fri, 29 Nov 2019 08:41:28 +0300 Subject: [PATCH] Reflecion of #589 --- sections/security/bcryptpasswords.russian.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sections/security/bcryptpasswords.russian.md b/sections/security/bcryptpasswords.russian.md index 25a3cccb..90fd453b 100644 --- a/sections/security/bcryptpasswords.russian.md +++ b/sections/security/bcryptpasswords.russian.md @@ -9,19 +9,21 @@ ### Пример кода ```javascript +try { // asynchronously generate a secure password using 10 hashing rounds -bcrypt.hash('myPassword', 10, function(err, hash) { + const hash = await bcrypt.hash('myPassword', 10); // Store secure hash in user record -}); -// compare a provided password input with saved hash -bcrypt.compare('somePassword', hash, function(err, match) { - if(match) { + // compare a provided password input with saved hash + const match = await bcrypt.compare('somePassword', hash); + if (match) { // Passwords match } else { // Passwords don't match } -}); +} catch { + logger.error('could not hash password.') +} ``` ### Что говорят другие блогеры