Performance: Local strategy (username/password)
MEDIUM IMPACT
This affects the server-side authentication process speed and the responsiveness of login interactions.
async validate(username: string, password: string) { const user = await this.userService.findByUsername(username); if (!user) return null; const isValid = await bcrypt.compare(password, user.password); if (!isValid) return null; return user; } // Additionally, use caching or rate limiting to reduce repeated DB calls
async validate(username: string, password: string) { const user = await this.userService.findByUsername(username); if (!user) return null; const isValid = bcrypt.compareSync(password, user.password); if (!isValid) return null; return user; }
| Pattern | Server CPU Usage | Response Delay | Blocking Behavior | Verdict |
|---|---|---|---|---|
| Synchronous password hash check | High CPU blocking | Increases by 50-100ms | Blocks event loop | [X] Bad |
| Asynchronous bcrypt.compare with caching | Lower CPU blocking | Minimal delay added | Non-blocking | [OK] Good |