From 3b057f2c2788657e32942984555fa581de9eae6b Mon Sep 17 00:00:00 2001 From: igophper <34326532+igophper@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:15:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=202FA=E6=94=AF=E6=8C=81=E5=89=8D=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E9=AA=8C=E8=AF=81=E7=A0=81=20(#5942)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #5940 --- backend/utils/mfa/mfa.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/utils/mfa/mfa.go b/backend/utils/mfa/mfa.go index 30b644a5e..841730e66 100644 --- a/backend/utils/mfa/mfa.go +++ b/backend/utils/mfa/mfa.go @@ -40,7 +40,6 @@ func ValidCode(code, intervalStr, secret string) bool { } totp := gotp.NewTOTP(secret, 6, interval, nil) now := time.Now().Unix() - strInt64 := strconv.FormatInt(now, 10) - id16, _ := strconv.Atoi(strInt64) - return totp.Verify(code, int64(id16)) + prevTime := now - int64(interval) + return totp.Verify(code, now) || totp.Verify(code, prevTime) }