浏览代码

Merge branch 'next' of https://gitee.com/zuohuaijun/Admin.NET into next

zuohuaijun 2 年之前
父节点
当前提交
5563608967
共有 1 个文件被更改,包括 13 次插入1 次删除
  1. 13 1
      Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs

+ 13 - 1
Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs

@@ -6,7 +6,6 @@
 
 using Furion.SpecificationDocument;
 using Lazy.Captcha.Core;
-using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionRequest.Types;
 
 namespace Admin.NET.Core.Service;
 
@@ -237,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,