Performance: User login flow
MEDIUM IMPACT
This affects the server response time and perceived page load speed during user authentication.
app.post('/login', async (req, res) => { const user = await db.findUserAsync(req.body.username); if (!user || user.password !== req.body.password) { return res.status(401).send('Unauthorized'); } req.session.user = user; res.redirect('/dashboard'); });
app.post('/login', (req, res) => { const user = db.findUser(req.body.username); if (!user) return res.status(401).send('Unauthorized'); if (user.password !== req.body.password) return res.status(401).send('Unauthorized'); req.session.user = user; res.redirect('/dashboard'); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous DB and password check | Minimal | 0 | 0 | [X] Bad |
| Asynchronous DB and password check | Minimal | 0 | 0 | [OK] Good |