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