fix(api/verification): handle max_daily_count config correctly

Fix the logic for code.max_daily_count setting to correctly handle:
- 0: Disable verification code service entirely
- -1: No limit on daily sends
- >0: Limit daily sends to the specified number

Previously both 0 and -1 were treated as unlimited, which was incorrect.
The documentation states 0 should disable the service.
master
veypi 1 week ago
parent 69efc4284b
commit 241d22dba6

@ -61,7 +61,11 @@ func sendCode(x *vigo.X, req *SendRequest) (*SendResponse, error) {
} }
// 检查每日发送次数限制 // 检查每日发送次数限制
// 配置说明: 0=禁用验证码功能, -1=不限制, >0=限制次数
maxDaily, _ := models.GetSettingInt(models.SettingCodeMaxDailyCount) maxDaily, _ := models.GetSettingInt(models.SettingCodeMaxDailyCount)
if maxDaily == 0 {
return nil, vigo.ErrForbidden.WithString("verification code service is disabled")
}
if maxDaily > 0 { if maxDaily > 0 {
startOfDay := time.Now().Truncate(24 * time.Hour) startOfDay := time.Now().Truncate(24 * time.Hour)
var dailyCount int64 var dailyCount int64

Loading…
Cancel
Save