From ffd6b764f1113ee5b9a724895a438c3c4a887721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E6=99=BA=E6=98=8E?= <390620652@qq.com> Date: Thu, 24 Aug 2023 11:44:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0removeIfFail=EF=BC=8C?= =?UTF-8?q?=E4=BA=A4=E7=94=B1=E5=BC=80=E5=8F=91=E8=80=85=E6=9D=A5=E5=86=B3?= =?UTF-8?q?=E5=AE=9A=E9=AA=8C=E8=AF=81=E7=A0=81=E6=98=AF=E5=90=A6=E5=8F=AA?= =?UTF-8?q?=E8=83=BD=E7=94=A8=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lazy.Captcha.Core/DefaultCaptcha.cs | 5 +++-- Lazy.Captcha.Core/ICaptcha.cs | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Lazy.Captcha.Core/DefaultCaptcha.cs b/Lazy.Captcha.Core/DefaultCaptcha.cs index 98ad275..4c2e16f 100644 --- a/Lazy.Captcha.Core/DefaultCaptcha.cs +++ b/Lazy.Captcha.Core/DefaultCaptcha.cs @@ -56,8 +56,9 @@ namespace Lazy.Captcha.Core /// 验证码id /// 用户输入的验证码 /// 校验成功时是否移除缓存(用于多次验证) + /// 校验失败时是否移除缓存 /// - public virtual bool Validate(string captchaId, string code, bool removeIfSuccess = true) + public virtual bool Validate(string captchaId, string code, bool removeIfSuccess = true,bool removeIfFail = true) { var val = _storage.Get(captchaId); var comparisonType = _options.IgnoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture; @@ -65,7 +66,7 @@ namespace Lazy.Captcha.Core !string.IsNullOrWhiteSpace(val) && string.Equals(val, code, comparisonType); - if (!success || (success && removeIfSuccess)) + if ((!success && removeIfFail) || (success && removeIfSuccess)) { _storage.Remove(captchaId); } diff --git a/Lazy.Captcha.Core/ICaptcha.cs b/Lazy.Captcha.Core/ICaptcha.cs index 54ace64..d37a808 100644 --- a/Lazy.Captcha.Core/ICaptcha.cs +++ b/Lazy.Captcha.Core/ICaptcha.cs @@ -22,7 +22,8 @@ namespace Lazy.Captcha.Core /// 楠岃瘉鐮乮d /// 鐢ㄦ埛杈撳叆鐨勯獙璇佺爜 /// 鏍¢獙鎴愬姛鏃舵槸鍚︾Щ闄ょ紦瀛(鐢ㄤ簬澶氭楠岃瘉) + /// 鏍¢獙澶辫触鏃舵槸鍚︾Щ闄 /// - bool Validate(string captchaId, string code, bool removeIfSuccess = true); + bool Validate(string captchaId, string code, bool removeIfSuccess = true, bool removeIfFail = true); } } -- Gitee