feat: 2FA支持前一个验证码 (#5942)

Refs #5940
pull/5950/head
igophper 4 months ago committed by GitHub
parent d3d018bd44
commit 3b057f2c27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -40,7 +40,6 @@ func ValidCode(code, intervalStr, secret string) bool {
} }
totp := gotp.NewTOTP(secret, 6, interval, nil) totp := gotp.NewTOTP(secret, 6, interval, nil)
now := time.Now().Unix() now := time.Now().Unix()
strInt64 := strconv.FormatInt(now, 10) prevTime := now - int64(interval)
id16, _ := strconv.Atoi(strInt64) return totp.Verify(code, now) || totp.Verify(code, prevTime)
return totp.Verify(code, int64(id16))
} }

Loading…
Cancel
Save