- Generate verification codes with crypto/rand instead of the
predictable time-seeded math/rand
- Count failed verification attempts and invalidate the code after
verify_max_attempts (default 5) failures, closing the unlimited
online brute force of the 6-digit code at the login endpoint
- Delete the verification record after a successful check so codes
are single use and can not be replayed within the validity window
- Add unit tests for code generation
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
Co-authored-by: Claude <noreply@anthropic.com>