From a667f1a65eb467c683f0bf29b436f64f9567ea7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 28 Oct 2022 14:25:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E7=BC=93=E5=AD=98?= =?UTF-8?q?=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 | 14 +++++++++----- .../Yi.Framework.ApiMicroservice/Program.cs | 1 + .../appsettings.Production.json | 4 +++- .../appsettings.Staging.json | 4 +++- .../Yi.Framework.ApiMicroservice/appsettings.json | 4 +++- .../Yi.Framework.Common/Models/GobalModel.cs | 2 ++ 6 files changed, 21 insertions(+), 8 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 cc338c89..26396acd 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/System/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/System/AccountController.cs @@ -76,11 +76,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers //先进行验证码的效验 var code = _cacheDb.Get($"Yi:Captcha:{loginDto.Uuid}"); - //暂时先放开 - //if (code != loginDto.Code) - //{ - // return Result.Error("验证码错误!"); - //} + //判断是否开启二维码效验 + if (GobalModel.LoginCodeEnable) + { + if (code != loginDto.Code) + { + return Result.Error("验证码错误!"); + } + } + var loginInfo = HttpContext.GetLoginLogInfo(); loginInfo.LoginUser = loginDto.UserName; diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs index 9fc5f3e0..9d5775c2 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs @@ -147,6 +147,7 @@ builder.Services.AddSingleton(); //ȫóʼֵ #endregion GobalModel.SqlLogEnable = Appsettings.appBool("SqlLog_Enable"); +GobalModel.LoginCodeEnable = Appsettings.appBool("LoginCode_Enable"); //----------------------------------------------------------------------------------------------------------- var app = builder.Build(); #region diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Production.json b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Production.json index c238933a..1442ad5d 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Production.json +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Production.json @@ -14,9 +14,11 @@ //ȫ "AllowedHosts": "*", + //ȫÿ //Sql־Ƿӡ "SqlLog_Enable": false, - + //¼άǷӡ + "LoginCode_Enable": false, //ݿá //ݿӸǷ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Staging.json b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Staging.json index c238933a..1442ad5d 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Staging.json +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Staging.json @@ -14,9 +14,11 @@ //ȫ "AllowedHosts": "*", + //ȫÿ //Sql־Ƿӡ "SqlLog_Enable": false, - + //¼άǷӡ + "LoginCode_Enable": false, //ݿá //ݿӸǷ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json index c238933a..1442ad5d 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json @@ -14,9 +14,11 @@ //ȫ "AllowedHosts": "*", + //ȫÿ //Sql־Ƿӡ "SqlLog_Enable": false, - + //¼άǷӡ + "LoginCode_Enable": false, //ݿá //ݿӸǷ diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/GobalModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/GobalModel.cs index 1a86dd15..099cf32f 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/Models/GobalModel.cs +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/GobalModel.cs @@ -9,5 +9,7 @@ namespace Yi.Framework.Common.Models public static class GobalModel { public static bool SqlLogEnable { get; set; } = true; + + public static bool LoginCodeEnable { get; set; } = true; } }