Merge remote-tracking branch 'upstream/v2'
This commit is contained in:
commit
d66205f8a2
@ -63,13 +63,14 @@ public class AppAuthService : IDynamicApiController, ITransient
|
||||
if (passwordErrorTimes >= passwdMaxErrorTimes)
|
||||
throw Oops.Oh(ErrorCodeEnum.D1027);
|
||||
|
||||
// 是否开启验证码
|
||||
if (await _sysConfigService.GetConfigValueByCode<bool>(ConfigConst.SysCaptcha))
|
||||
{
|
||||
// 判断验证码
|
||||
if (!_captcha.Validate(input.CodeId.ToString(), input.Code))
|
||||
throw Oops.Oh(ErrorCodeEnum.D0008);
|
||||
}
|
||||
// 判断是否开启验证码并校验
|
||||
var tenant = _sysCacheService.Get<List<SysTenant>>(CacheConst.KeyTenant)?.WhereIF(input.TenantId > 0, u => u.Id == input.TenantId).FirstOrDefault();
|
||||
if (tenant.Captcha == true && !_captcha.Validate(input.CodeId.ToString(), input.Code))
|
||||
throw Oops.Oh(ErrorCodeEnum.D0008);
|
||||
|
||||
// 租户是否被禁用
|
||||
if (tenant != null && tenant.Status == StatusEnum.Disable)
|
||||
throw Oops.Oh(ErrorCodeEnum.Z1003);
|
||||
|
||||
// 账号是否存在
|
||||
var user = await _sysUserRep.AsQueryable().Includes(t => t.SysOrg).ClearFilter().FirstAsync(u => u.Account.Equals(input.Account));
|
||||
@ -79,11 +80,6 @@ public class AppAuthService : IDynamicApiController, ITransient
|
||||
if (user.Status == StatusEnum.Disable)
|
||||
throw Oops.Oh(ErrorCodeEnum.D1017);
|
||||
|
||||
// 租户是否被禁用
|
||||
var tenant = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysTenant>>().GetByIdAsync(user.TenantId);
|
||||
if (tenant != null && tenant.Status == StatusEnum.Disable)
|
||||
throw Oops.Oh(ErrorCodeEnum.Z1003);
|
||||
|
||||
// 国密SM2解密(前端密码传输SM2加密后的)
|
||||
try
|
||||
{
|
||||
|
||||
@ -20,9 +20,9 @@
|
||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
||||
<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.1" Aliases="BouncyCastleV2" />
|
||||
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.17.1" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.7.15" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.7.15" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.7.15" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.7.17" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.7.17" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.7.17" />
|
||||
<PackageReference Include="Hardware.Info" Version="101.0.1" />
|
||||
<PackageReference Include="Hashids.net" Version="1.7.0" />
|
||||
<PackageReference Include="IPTools.China" Version="1.6.0" />
|
||||
@ -44,11 +44,11 @@
|
||||
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.3" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.7.0" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.10.0" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.179" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.180" />
|
||||
<PackageReference Include="SSH.NET" Version="2024.2.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.0.2" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1188" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1189" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -41,15 +41,15 @@ public class ConfigConst
|
||||
/// </summary>
|
||||
public const string SysSingleLogin = "sys_single_login";
|
||||
|
||||
/// <summary>
|
||||
/// 登录二次验证
|
||||
/// </summary>
|
||||
public const string SysSecondVer = "sys_second_ver";
|
||||
///// <summary>
|
||||
///// 登录二次验证
|
||||
///// </summary>
|
||||
//public const string SysSecondVer = "sys_second_ver";
|
||||
|
||||
/// <summary>
|
||||
/// 图形验证码
|
||||
/// </summary>
|
||||
public const string SysCaptcha = "sys_captcha";
|
||||
///// <summary>
|
||||
///// 图形验证码
|
||||
///// </summary>
|
||||
//public const string SysCaptcha = "sys_captcha";
|
||||
|
||||
/// <summary>
|
||||
/// Token过期时间
|
||||
|
||||
@ -28,8 +28,7 @@ public class LoginInput
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
/// </summary>
|
||||
//[Required(ErrorMessage = "租户Id不能为空")]
|
||||
public long TenantId { get; set; }
|
||||
public long TenantId { get; set; } = SqlSugarConst.DefaultTenantId;
|
||||
|
||||
/// <summary>
|
||||
/// 验证码Id
|
||||
|
||||
@ -59,7 +59,9 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
if (passwordErrorTimes > passwordMaxErrorTimes) throw Oops.Oh(ErrorCodeEnum.D1027);
|
||||
|
||||
// 判断是否开启验证码并校验
|
||||
if (await _sysConfigService.GetConfigValueByCode<bool>(ConfigConst.SysCaptcha) && !_captcha.Validate(input.CodeId.ToString(), input.Code)) throw Oops.Oh(ErrorCodeEnum.D0008);
|
||||
var tenant = _sysCacheService.Get<List<SysTenant>>(CacheConst.KeyTenant)?.WhereIF(input.TenantId > 0, u => u.Id == input.TenantId).FirstOrDefault();
|
||||
if (tenant.Captcha == true && !_captcha.Validate(input.CodeId.ToString(), input.Code))
|
||||
throw Oops.Oh(ErrorCodeEnum.D0008);
|
||||
|
||||
// 获取并验证账号
|
||||
var user = await GetLoginUser(input.TenantId, account: input.Account);
|
||||
@ -385,7 +387,11 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
{
|
||||
try
|
||||
{
|
||||
_sysCacheService.Set($"{CacheConst.KeyConfig}{ConfigConst.SysCaptcha}", false);
|
||||
// 关闭默认租户验证码验证
|
||||
var tenantList = _sysCacheService.Get<List<SysTenant>>(CacheConst.KeyTenant);
|
||||
var tenant = tenantList.FirstOrDefault(u => u.Id == SqlSugarConst.DefaultTenantId);
|
||||
tenant.Captcha = false;
|
||||
_sysCacheService.Set(CacheConst.KeyTenant, tenantList);
|
||||
|
||||
await Login(new LoginInput
|
||||
{
|
||||
@ -394,7 +400,9 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
TenantId = SqlSugarConst.DefaultTenantId
|
||||
});
|
||||
|
||||
_sysCacheService.Remove($"{CacheConst.KeyConfig}{ConfigConst.SysCaptcha}");
|
||||
// 启用默认租户验证码验证
|
||||
tenant.Captcha = true;
|
||||
_sysCacheService.Set(CacheConst.KeyTenant, tenantList);
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
@ -13,16 +13,16 @@ namespace Admin.NET.Plugin.GoView.Service;
|
||||
[ApiDescriptionSettings(GoViewConst.GroupName, Module = "goview", Name = "sys", Order = 100, Description = "系统登录")]
|
||||
public class GoViewSysService : IDynamicApiController
|
||||
{
|
||||
private readonly SysAuthService _sysAuthService;
|
||||
private readonly SqlSugarRepository<SysUser> _sysUserRep;
|
||||
private readonly SysAuthService _sysAuthService;
|
||||
private readonly SysCacheService _sysCacheService;
|
||||
|
||||
public GoViewSysService(SysAuthService sysAuthService,
|
||||
SqlSugarRepository<SysUser> sysUserRep,
|
||||
public GoViewSysService(SqlSugarRepository<SysUser> sysUserRep,
|
||||
SysAuthService sysAuthService,
|
||||
SysCacheService sysCacheService)
|
||||
{
|
||||
_sysAuthService = sysAuthService;
|
||||
_sysUserRep = sysUserRep;
|
||||
_sysAuthService = sysAuthService;
|
||||
_sysCacheService = sysCacheService;
|
||||
}
|
||||
|
||||
@ -37,7 +37,11 @@ public class GoViewSysService : IDynamicApiController
|
||||
// 设置默认租户
|
||||
input.TenantId ??= SqlSugarConst.DefaultTenantId;
|
||||
|
||||
_sysCacheService.Set($"{CacheConst.KeyConfig}{ConfigConst.SysCaptcha}", false);
|
||||
// 关闭默认租户验证码验证
|
||||
var tenantList = _sysCacheService.Get<List<SysTenant>>(CacheConst.KeyTenant);
|
||||
var tenant = tenantList.FirstOrDefault(u => u.Id == SqlSugarConst.DefaultTenantId);
|
||||
tenant.Captcha = false;
|
||||
_sysCacheService.Set(CacheConst.KeyTenant, tenantList);
|
||||
|
||||
input.Password = CryptogramUtil.SM2Encrypt(input.Password);
|
||||
var loginResult = await _sysAuthService.Login(new LoginInput()
|
||||
@ -46,7 +50,9 @@ public class GoViewSysService : IDynamicApiController
|
||||
Password = input.Password,
|
||||
});
|
||||
|
||||
_sysCacheService.Remove($"{CacheConst.KeyConfig}{ConfigConst.SysCaptcha}");
|
||||
// 启用默认租户验证码验证
|
||||
tenant.Captcha = true;
|
||||
_sysCacheService.Set(CacheConst.KeyTenant, tenantList);
|
||||
|
||||
var sysUser = await _sysUserRep.AsQueryable().ClearFilter().FirstAsync(u => u.Account.Equals(input.Username));
|
||||
return new GoViewLoginOutput()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user