Skip to content

Commit

Permalink
hash pass bcrypt 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanna committed Nov 17, 2024
1 parent 1503425 commit 057a3da
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions js/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,20 @@ app.delete('/api/reviews/:id', async (req, res) => {
// admin
const adminPasswordHash = process.env.ADMIN_PASSWORD_HASH;


app.post('/check-password', async (req, res) => {
const { password } = req.body;
const isValid = await bcrypt.compare(password, adminPasswordHash);
res.json({ success: isValid });
const { password } = req.body;
console.log('Отриманий пароль:', password);
console.log('Хеш у .env:', adminPasswordHash); // Додано логування хешу

try {
const isValid = await bcrypt.compare(password, adminPasswordHash);
console.log('Результат перевірки:', isValid);
res.json({ success: isValid });
} catch (error) {
console.error('Помилка перевірки пароля:', error);
res.status(500).json({ success: false, message: 'Помилка сервера' });
}
});


Expand Down

0 comments on commit 057a3da

Please sign in to comment.