From 9f5829876cfc740f37ef41c781543bf5ea7a5129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 28 Oct 2022 14:10:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=AA=8C=E8=AF=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/System/AccountController.cs | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 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 db3e96f0..cc338c89 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/System/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/System/AccountController.cs @@ -35,7 +35,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers private SecurityCodeHelper _securityCode; private IRepository _repository; private CacheInvoker _cacheDb; - public AccountController(ILogger logger, IUserService iUserService, JwtInvoker jwtInvoker, SecurityCodeHelper securityCode,CacheInvoker cacheInvoker) + public AccountController(ILogger logger, IUserService iUserService, JwtInvoker jwtInvoker, SecurityCodeHelper securityCode, CacheInvoker cacheInvoker) { _iUserService = iUserService; _jwtInvoker = jwtInvoker; @@ -73,6 +73,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers //先效验验证码和UUID //登录还需要进行登录日志的落库 + //先进行验证码的效验 + + var code = _cacheDb.Get($"Yi:Captcha:{loginDto.Uuid}"); + //暂时先放开 + //if (code != loginDto.Code) + //{ + // return Result.Error("验证码错误!"); + //} + var loginInfo = HttpContext.GetLoginLogInfo(); loginInfo.LoginUser = loginDto.UserName; loginInfo.LogMsg = "登录成功!"; @@ -160,22 +169,6 @@ namespace Yi.Framework.ApiMicroservice.Controllers return Result.Success().SetData(routers); } - ///// - ///// 更新已登录用户的用户信息 - ///// - ///// - ///// - //[HttpPut] - //public async Task UpdateUserByHttp(UserEntity user) - //{ - // //当然,密码是不能给他修改的 - // user.Password = null; - // user.Salt = null; - - // //修改需要赋值上主键哦 - // user.Id = HttpContext.GetUserIdInfo(); - // return Result.Success().SetStatus(await _iUserService._repository.UpdateIgnoreNullAsync(user)); - //} /// /// 自己更新密码 @@ -206,8 +199,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers var code = _securityCode.GetRandomEnDigitalText(4); //将uuid与code,Redis缓存中心化保存起来,登录根据uuid比对即可 //10分钟过期 - _cacheDb.Set($"Yi:Captcha:{uuid}",code,new TimeSpan(0,10,0)); - var imgbyte = _securityCode.GetEnDigitalCodeByte(code); + _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 }); } }