😎修复验证码调整错误
This commit is contained in:
parent
4735f4c0a1
commit
8a5fa59d26
@ -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.16" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.7.16" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.7.16" />
|
||||
<PackageReference Include="Hardware.Info" Version="101.0.1" />
|
||||
<PackageReference Include="Hashids.net" Version="1.7.0" />
|
||||
<PackageReference Include="IPTools.China" Version="1.6.0" />
|
||||
|
||||
@ -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
|
||||
|
||||
@ -58,8 +58,10 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
if (passwordMaxErrorTimes < 1) passwordMaxErrorTimes = 5;
|
||||
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,8 +387,6 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
{
|
||||
try
|
||||
{
|
||||
_sysCacheService.Set($"{CacheConst.KeyConfig}{ConfigConst.SysCaptcha}", false);
|
||||
|
||||
await Login(new LoginInput
|
||||
{
|
||||
Account = auth.UserName,
|
||||
@ -394,8 +394,6 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
TenantId = SqlSugarConst.DefaultTenantId
|
||||
});
|
||||
|
||||
_sysCacheService.Remove($"{CacheConst.KeyConfig}{ConfigConst.SysCaptcha}");
|
||||
|
||||
return 200;
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@ -15,15 +15,12 @@ public class GoViewSysService : IDynamicApiController
|
||||
{
|
||||
private readonly SysAuthService _sysAuthService;
|
||||
private readonly SqlSugarRepository<SysUser> _sysUserRep;
|
||||
private readonly SysCacheService _sysCacheService;
|
||||
|
||||
public GoViewSysService(SysAuthService sysAuthService,
|
||||
SqlSugarRepository<SysUser> sysUserRep,
|
||||
SysCacheService sysCacheService)
|
||||
SqlSugarRepository<SysUser> sysUserRep)
|
||||
{
|
||||
_sysAuthService = sysAuthService;
|
||||
_sysUserRep = sysUserRep;
|
||||
_sysCacheService = sysCacheService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -37,8 +34,6 @@ public class GoViewSysService : IDynamicApiController
|
||||
// 设置默认租户
|
||||
input.TenantId ??= SqlSugarConst.DefaultTenantId;
|
||||
|
||||
_sysCacheService.Set($"{CacheConst.KeyConfig}{ConfigConst.SysCaptcha}", false);
|
||||
|
||||
input.Password = CryptogramUtil.SM2Encrypt(input.Password);
|
||||
var loginResult = await _sysAuthService.Login(new LoginInput()
|
||||
{
|
||||
@ -46,8 +41,6 @@ public class GoViewSysService : IDynamicApiController
|
||||
Password = input.Password,
|
||||
});
|
||||
|
||||
_sysCacheService.Remove($"{CacheConst.KeyConfig}{ConfigConst.SysCaptcha}");
|
||||
|
||||
var sysUser = await _sysUserRep.AsQueryable().ClearFilter().FirstAsync(u => u.Account.Equals(input.Username));
|
||||
return new GoViewLoginOutput()
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user