😎1、优化鉴权时服务作用域 2、增加登录时更新登录信息 3、升级nuget包

This commit is contained in:
zuohuaijun 2024-06-23 01:07:18 +08:00
parent 413a14061f
commit 4047cf6e5c
4 changed files with 17 additions and 3 deletions

View File

@ -34,7 +34,7 @@
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.2" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.3.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.5.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.158" />
<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.1031" />

View File

@ -236,6 +236,19 @@ public class SysAuthService : IDynamicApiController, ITransient
// Swagger Knife4UI-AfterScript登录脚本
// ke.global.setAllHeader('Authorization', 'Bearer ' + ke.response.headers['access-token']);
// 更新用户登录信息
string remoteIPv4 = App.HttpContext.GetRemoteIpAddressToIPv4();
(string ipLocation, double? longitude, double? latitude) = DatabaseLoggingWriter.GetIpAddress(remoteIPv4);
user.LastLoginIp = remoteIPv4;
user.LastLoginAddress = ipLocation;
user.LastLoginTime = DateTime.Now;
await _sysUserRep.AsUpdateable(user).UpdateColumns(it => new
{
it.LastLoginIp,
it.LastLoginAddress,
it.LastLoginTime,
}).ExecuteCommandAsync();
return new LoginOutput
{
AccessToken = accessToken,

View File

@ -86,7 +86,8 @@ namespace Admin.NET.Web.Core
// 接口路由权限
var path = httpContext.Request.Path.ToString();
var sysRoleService = App.GetRequiredService<SysRoleService>();
var serviceScope = httpContext.RequestServices.CreateScope();
var sysRoleService = serviceScope.ServiceProvider.GetRequiredService<SysRoleService>();
// 若当前路由在基础接口资源集合里面则放行
var baseApis = await sysRoleService.GetBaseApiList();

View File

@ -24,7 +24,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Rezero.Api" Version="1.7.1" />
<PackageReference Include="Rezero.Api" Version="1.7.2" />
</ItemGroup>
<ItemGroup>