Created
October 18, 2025 13:54
-
-
Save mcsee/ba50d84d91ab9e26cd0a7d84a5fec633 to your computer and use it in GitHub Desktop.
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bcrypt from 'bcrypt'; | |
| app.post('/login', async (req, res) => { | |
| const { username, password } = req.body; | |
| const user = await Users.findOne({ username }); | |
| if (!user) return res.status(401).send('Invalid credentials'); | |
| const valid = await bcrypt.compare(password, user.password); | |
| if (!valid) return res.status(401).send('Invalid credentials'); | |
| res.send('Login successful'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment