Created
October 18, 2025 13:54
-
-
Save mcsee/ba50d84d91ab9e26cd0a7d84a5fec633 to your computer and use it in GitHub Desktop.
Revisions
-
mcsee created this gist
Oct 18, 2025 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ 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'); });