From 189d7c47190846bcf7b08705e728773deee6c3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Thu, 27 Oct 2022 20:54:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/System/AccountController.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/System/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/System/AccountController.cs index 6d34d03f..db3e96f0 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/System/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/System/AccountController.cs @@ -34,13 +34,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers private ILogger _logger; private SecurityCodeHelper _securityCode; private IRepository _repository; - public AccountController(ILogger logger, IUserService iUserService, JwtInvoker jwtInvoker, SecurityCodeHelper securityCode) + private CacheInvoker _cacheDb; + public AccountController(ILogger logger, IUserService iUserService, JwtInvoker jwtInvoker, SecurityCodeHelper securityCode,CacheInvoker cacheInvoker) { _iUserService = iUserService; _jwtInvoker = jwtInvoker; _logger = logger; _securityCode = securityCode; _repository = iUserService._repository; + _cacheDb = cacheInvoker; } /// @@ -203,7 +205,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers var uuid = Guid.NewGuid(); var code = _securityCode.GetRandomEnDigitalText(4); //将uuid与code,Redis缓存中心化保存起来,登录根据uuid比对即可 - var imgbyte = _securityCode.GetEnDigitalCodeByte(code); + //10分钟过期 + _cacheDb.Set($"Yi:Captcha:{uuid}",code,new TimeSpan(0,10,0)); + var imgbyte = _securityCode.GetEnDigitalCodeByte(code); return Result.Success().SetData(new { uuid = uuid, img = imgbyte }); } }