😎1、优化水印 2、忽略路由大小写 3、代码优化
This commit is contained in:
parent
716884da90
commit
51695c9e84
@ -1,14 +1,20 @@
|
||||
{
|
||||
"$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json",
|
||||
|
||||
// 详细数据库配置见SqlSugar官网(第一个为默认库)
|
||||
// 详细数据库配置见SqlSugar官网(第一个为默认库),极力推荐 PostgreSQL 数据库
|
||||
// 数据库连接字符串参考地址:https://www.connectionstrings.com/
|
||||
"DbConnection": {
|
||||
"EnableConsoleSql": true, // 启用控制台打印SQL
|
||||
"ConnectionConfigs": [
|
||||
{
|
||||
//"ConfigId": "1300000000001", // 默认库标识-禁止修改
|
||||
"DbType": "Sqlite", // MySql、SqlServer、Sqlite、Oracle、PostgreSQL、Dm、Kdbndp、Oscar、MySqlConnector、Access、OpenGauss、QuestDB、HG、ClickHouse、GBase、Odbc、Custom
|
||||
"ConnectionString": "DataSource=./Admin.NET.db", // 库连接字符串
|
||||
"ConnectionString": "DataSource=./Admin.NET.db", // Sqlite 库连接字符串
|
||||
//"ConnectionString": "PORT=5432;DATABASE=xxx;HOST=localhost;PASSWORD=xxx;USER ID=xxx", // PostgreSQL 库连接字符串
|
||||
//"ConnectionString": "Server=localhost;Database=xxx;Uid=xxx;Pwd=xxx;SslMode=None;", // MySql 库连接字符串",
|
||||
//"ConnectionString": "User Id=xxx; Password=xxx; Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)))", // Oracle 库连接字符串
|
||||
//"ConnectionString": "Server=localhost;Database=xxx;User Id=xxx;Password=xxx;", // SqlServer 库连接字符串
|
||||
|
||||
//"SlaveConnectionConfigs": [ // 读写分离/主从
|
||||
// {
|
||||
// "HitRate": 10,
|
||||
|
||||
@ -59,7 +59,7 @@ public class AppAuthService : IDynamicApiController, ITransient
|
||||
// 判断密码错误次数(缓存30分钟)
|
||||
var keyPasswordErrorTimes = $"{CacheConst.KeyPasswordErrorTimes}{input.Account}";
|
||||
var passwordErrorTimes = _sysCacheService.Get<int>(keyPasswordErrorTimes);
|
||||
var passwdMaxErrorTimes = await _sysConfigService.GetConfigValue<int>(CommonConst.SysPasswdMaxErrorTimes);
|
||||
var passwdMaxErrorTimes = await _sysConfigService.GetConfigValue<int>(CommonConst.SysPasswordMaxErrorTimes);
|
||||
if (passwordErrorTimes >= passwdMaxErrorTimes)
|
||||
throw Oops.Oh(ErrorCodeEnum.D1027);
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="2.0.24" />
|
||||
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="3.0.0" />
|
||||
<PackageReference Include="AngleSharp" Version="1.1.2" />
|
||||
<PackageReference Include="AspectCore.Extensions.Reflection" Version="2.4.0" />
|
||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
||||
@ -37,7 +37,7 @@
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.159" />
|
||||
<PackageReference Include="SSH.NET" Version="2024.0.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.1" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1032" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1033" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -25,7 +25,7 @@ public class CommonConst
|
||||
/// <summary>
|
||||
/// 密码最大错误次数
|
||||
/// </summary>
|
||||
public const string SysPasswdMaxErrorTimes = "sys_passwd_max_error_times";
|
||||
public const string SysPasswordMaxErrorTimes = "sys_password_max_error_times";
|
||||
|
||||
/// <summary>
|
||||
/// 登录二次验证
|
||||
|
||||
@ -21,7 +21,7 @@ public class SysConfigSeedData : ISqlSugarEntitySeedData<SysConfig>
|
||||
{
|
||||
new SysConfig{ Id=1300000000101, Name="演示环境", Code="sys_demo", Value="False", SysFlag=YesNoEnum.Y, Remark="演示环境", OrderNo=10, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
|
||||
new SysConfig{ Id=1300000000111, Name="默认密码", Code="sys_password", Value="123456", SysFlag=YesNoEnum.Y, Remark="默认密码", OrderNo=20, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
|
||||
new SysConfig{ Id=1300000000121, Name="密码最大错误次数", Code="sys_passwd_max_error_times", Value="5", SysFlag=YesNoEnum.Y, Remark="允许密码最大输入错误次数", OrderNo=30, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
|
||||
new SysConfig{ Id=1300000000121, Name="密码最大错误次数", Code="sys_password_max_error_times", Value="5", SysFlag=YesNoEnum.Y, Remark="允许密码最大输入错误次数", OrderNo=30, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
|
||||
new SysConfig{ Id=1300000000131, Name="记录操作日志", Code="sys_oplog", Value="True", SysFlag=YesNoEnum.Y, Remark="是否记录操作日志", OrderNo=40, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
|
||||
new SysConfig{ Id=1300000000141, Name="开启单设备登录", Code="sys_single_login", Value="False", SysFlag=YesNoEnum.Y, Remark="是否开启单设备登录", OrderNo=50, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
|
||||
new SysConfig{ Id=1300000000151, Name="开启登录二次验证", Code="sys_second_ver", Value="False", SysFlag=YesNoEnum.Y, Remark="是否开启登录二次验证", OrderNo=60, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
|
||||
|
||||
@ -95,4 +95,9 @@ public class LoginUserOutput
|
||||
/// 角色集合
|
||||
/// </summary>
|
||||
public List<long> RoleIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 水印文字
|
||||
/// </summary>
|
||||
public string WatermarkText { get; set; }
|
||||
}
|
||||
@ -65,7 +65,7 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
// 判断密码错误次数(缓存30分钟)
|
||||
var keyPasswordErrorTimes = $"{CacheConst.KeyPasswordErrorTimes}{input.Account}";
|
||||
var passwordErrorTimes = _sysCacheService.Get<int>(keyPasswordErrorTimes);
|
||||
var passwdMaxErrorTimes = await _sysConfigService.GetConfigValue<int>(CommonConst.SysPasswdMaxErrorTimes);
|
||||
var passwdMaxErrorTimes = await _sysConfigService.GetConfigValue<int>(CommonConst.SysPasswordMaxErrorTimes);
|
||||
if (passwordErrorTimes >= passwdMaxErrorTimes)
|
||||
throw Oops.Oh(ErrorCodeEnum.D1027);
|
||||
|
||||
@ -127,16 +127,16 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
/// 验证用户密码
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="keyPasswordErrorTims"></param>
|
||||
/// <param name="keyPasswordErrorTimes"></param>
|
||||
/// <param name="passwordErrorTimes"></param>
|
||||
/// <param name="user"></param>
|
||||
private void VerifyPassword(LoginInput input, string keyPasswordErrorTims, int passwordErrorTimes, SysUser user)
|
||||
private void VerifyPassword(LoginInput input, string keyPasswordErrorTimes, int passwordErrorTimes, SysUser user)
|
||||
{
|
||||
if (CryptogramUtil.CryptoType == CryptogramEnum.MD5.ToString())
|
||||
{
|
||||
if (!user.Password.Equals(MD5Encryption.Encrypt(input.Password)))
|
||||
{
|
||||
_sysCacheService.Set(keyPasswordErrorTims, ++passwordErrorTimes, TimeSpan.FromMinutes(30));
|
||||
_sysCacheService.Set(keyPasswordErrorTimes, ++passwordErrorTimes, TimeSpan.FromMinutes(30));
|
||||
throw Oops.Oh(ErrorCodeEnum.D1000);
|
||||
}
|
||||
}
|
||||
@ -144,7 +144,7 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
{
|
||||
if (!CryptogramUtil.Decrypt(user.Password).Equals(input.Password))
|
||||
{
|
||||
_sysCacheService.Set(keyPasswordErrorTims, ++passwordErrorTimes, TimeSpan.FromMinutes(30));
|
||||
_sysCacheService.Set(keyPasswordErrorTimes, ++passwordErrorTimes, TimeSpan.FromMinutes(30));
|
||||
throw Oops.Oh(ErrorCodeEnum.D1000);
|
||||
}
|
||||
}
|
||||
@ -274,6 +274,10 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
// 获取角色集合
|
||||
var roleIds = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysUserRole>>().AsQueryable()
|
||||
.Where(u => u.UserId == user.Id).Select(u => u.RoleId).ToListAsync();
|
||||
// 获取水印文字(若系统水印为空则全局为空)
|
||||
var watermarkText = await _sysConfigService.GetConfigValue<string>("sys_web_watermark");
|
||||
if (!string.IsNullOrWhiteSpace(watermarkText))
|
||||
watermarkText += $"-{user.RealName}"; // $"-{user.RealName}-{_httpContextAccessor.HttpContext.GetRemoteIp()}-{DateTime.Now}";
|
||||
|
||||
return new LoginUserOutput
|
||||
{
|
||||
@ -292,7 +296,8 @@ public class SysAuthService : IDynamicApiController, ITransient
|
||||
OrgType = org?.Type,
|
||||
PosName = pos?.Name,
|
||||
Buttons = buttons,
|
||||
RoleIds = roleIds
|
||||
RoleIds = roleIds,
|
||||
WatermarkText = watermarkText
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -252,9 +252,6 @@ public class SysConfigService : IDynamicApiController, ITransient
|
||||
var sysIcp = await GetConfigValue<string>("sys_web_icp");
|
||||
var sysIcpUrl = await GetConfigValue<string>("sys_web_icpUrl");
|
||||
|
||||
//var ip = _httpContextAccessor.HttpContext.GetRemoteIp();
|
||||
//var watermark = $"{sysWatermark}-{DateTime.Now}-{ip}-{_userManager.RealName}";
|
||||
|
||||
return new
|
||||
{
|
||||
SysLogo = sysLogo,
|
||||
|
||||
@ -16,7 +16,8 @@ public class SysDictDataService : IDynamicApiController, ITransient
|
||||
private readonly SysCacheService _sysCacheService;
|
||||
private readonly SqlSugarRepository<SysDictData> _sysDictDataRep;
|
||||
|
||||
public SysDictDataService(SqlSugarRepository<SysDictData> sysDictDataRep, SysCacheService sysCacheService)
|
||||
public SysDictDataService(SqlSugarRepository<SysDictData> sysDictDataRep,
|
||||
SysCacheService sysCacheService)
|
||||
{
|
||||
_sysDictDataRep = sysDictDataRep;
|
||||
_sysCacheService = sysCacheService;
|
||||
@ -149,7 +150,7 @@ public class SysDictDataService : IDynamicApiController, ITransient
|
||||
[NonAction]
|
||||
public async Task<List<SysDictData>> GetDictDataListByDictTypeId(long dictTypeId)
|
||||
{
|
||||
var dictType = await _sysDictDataRep.GetByIdAsync(dictTypeId);
|
||||
var dictType = await _sysDictDataRep.ChangeRepository<SqlSugarRepository<SysDictType>>().GetByIdAsync(dictTypeId);
|
||||
var dictDataList = _sysCacheService.Get<List<SysDictData>>($"{CacheConst.KeyDict}{dictTypeId}");
|
||||
|
||||
if (dictDataList == null)
|
||||
|
||||
@ -185,34 +185,30 @@ public static class SqlSugarSetup
|
||||
// 若当前用户非空(web线程时)
|
||||
if (App.User != null)
|
||||
{
|
||||
dynamic entityValue = entityInfo.EntityValue;
|
||||
if (entityInfo.PropertyName == nameof(EntityTenantId.TenantId))
|
||||
{
|
||||
var tenantId = ((dynamic)entityInfo.EntityValue).TenantId;
|
||||
if (tenantId == null || tenantId == 0)
|
||||
if (entityValue.TenantId == 0)
|
||||
entityInfo.SetValue(App.User.FindFirst(ClaimConst.TenantId)?.Value);
|
||||
}
|
||||
else if (entityInfo.PropertyName == nameof(EntityBase.CreateUserId))
|
||||
{
|
||||
var createUserId = ((dynamic)entityInfo.EntityValue).CreateUserId;
|
||||
if (createUserId == 0 || createUserId == null)
|
||||
if (entityValue.CreateUserId == 0)
|
||||
entityInfo.SetValue(App.User.FindFirst(ClaimConst.UserId)?.Value);
|
||||
}
|
||||
else if (entityInfo.PropertyName == nameof(EntityBase.CreateUserName))
|
||||
{
|
||||
var createUserName = ((dynamic)entityInfo.EntityValue).CreateUserName;
|
||||
if (string.IsNullOrEmpty(createUserName))
|
||||
if (string.IsNullOrWhiteSpace(entityValue.CreateUserName))
|
||||
entityInfo.SetValue(App.User.FindFirst(ClaimConst.RealName)?.Value);
|
||||
}
|
||||
else if (entityInfo.PropertyName == nameof(EntityBaseData.CreateOrgId))
|
||||
{
|
||||
var createOrgId = ((dynamic)entityInfo.EntityValue).CreateOrgId;
|
||||
if (createOrgId == 0 || createOrgId == null)
|
||||
if (entityValue.CreateOrgId == 0)
|
||||
entityInfo.SetValue(App.User.FindFirst(ClaimConst.OrgId)?.Value);
|
||||
}
|
||||
else if (entityInfo.PropertyName == nameof(EntityBaseData.CreateOrgName))
|
||||
{
|
||||
var createOrgName = ((dynamic)entityInfo.EntityValue).CreateOrgName;
|
||||
if (string.IsNullOrEmpty(createOrgName))
|
||||
if (string.IsNullOrWhiteSpace(entityValue.CreateOrgName))
|
||||
entityInfo.SetValue(App.User.FindFirst(ClaimConst.OrgName)?.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,12 +91,12 @@ namespace Admin.NET.Web.Core
|
||||
|
||||
// 若当前路由在基础接口资源集合里面则放行
|
||||
var baseApis = await sysRoleService.GetBaseApiList();
|
||||
if (baseApis.Exists(u => path.Contains(u, StringComparison.CurrentCulture)))
|
||||
if (baseApis.Exists(u => path.Contains(u, StringComparison.CurrentCultureIgnoreCase)))
|
||||
return true;
|
||||
|
||||
// 判断当前路由是否在角色已有接口资源里面
|
||||
var roleApis = await sysRoleService.GetUserApiList();
|
||||
return roleApis.Exists(u => path.Contains(u, StringComparison.CurrentCulture));
|
||||
return roleApis.Exists(u => path.Contains(u, StringComparison.CurrentCultureIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -24,7 +24,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Rezero.Api" Version="1.7.4" />
|
||||
<PackageReference Include="Rezero.Api" Version="1.7.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { Session } from '/@/utils/storage';
|
||||
import { Local, Session } from '/@/utils/storage';
|
||||
import Watermark from '/@/utils/watermark';
|
||||
import { useThemeConfig } from '/@/stores/themeConfig';
|
||||
|
||||
import { getAPI } from '/@/utils/axios-utils';
|
||||
import { SysAuthApi, SysConstApi, SysDictTypeApi } from '/@/api-services/api';
|
||||
@ -88,6 +90,15 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
// 增加了下面代码,引起当前会话的用户信息不会刷新,如:重新提交的头像不更新,需要新开一个页面才能正确显示
|
||||
// Session.set('userInfo', userInfos);
|
||||
|
||||
// 用户水印
|
||||
const storesThemeConfig = useThemeConfig();
|
||||
storesThemeConfig.themeConfig.watermarkText = d.watermarkText ?? '';
|
||||
if (storesThemeConfig.themeConfig.isWatermark) Watermark.set(storesThemeConfig.themeConfig.watermarkText);
|
||||
else Watermark.del();
|
||||
|
||||
Local.remove('themeConfig');
|
||||
Local.set('themeConfig', storesThemeConfig.themeConfig);
|
||||
|
||||
resolve(userInfos);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user