Unlimited password guessing in agent-written backends usually comes down to a login route that does exactly what the prompt asked. It looks up the email, compares the hash, returns a token, and passes every test you thought to write. Nothing in it stops someone from guessing passwords against one account as fast as the server answers.
The handler that looks finished
Here's a typical login handler (Express, trimmed). As far as it goes, it's correct:
app . post ( "/login" , async ( req , res ) => { const { email , password } = req . body ; const user = await db . users . findByEmail ( email ) ; if ( ! user || ! ( await bcrypt . compare ( password , user . passwordHash ) ) ) { return res . status ( 401 ) . json ( { error : "Invalid credentials" } ) ; } res . json ( { token : signToken ( user . id ) } ) ; } ) ;
Enter fullscreen mode
Exit fullscreen mode
The happy path works, the wrong-password path returns a 401, and a reviewer skimming the diff sees clean code.…