Code RoomLogin accepts unlimited attempts
HardPrep Room Coding #2180

Login accepts unlimited attempts

Code reviewSecurityNetworking & APIsSenior–Staff~20 min

Review this Express login route.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1app.post('/login', async (req, res) => {
2 const { email, password } = req.body;
3 const user = await Users.findByEmail(email);
4 if (!user) return res.status(401).json({ error: 'invalid' });
5 const ok = await bcrypt.compare(password, user.passwordHash);
6 if (!ok) return res.status(401).json({ error: 'invalid' });
7 const token = signJwt({ sub: user.id });
8 res.json({ token });
9});
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.