🍒 fix(auth): 调整token版本更新时机

This commit is contained in:
喵你个汪呀 2025-08-28 19:50:29 +08:00
parent 1a05dbe0fa
commit a6fd3a1408

View File

@ -229,6 +229,7 @@ public class SysAuthService : IDynamicApiController, ITransient
await App.GetRequiredService<SysOnlineUserService>().SingleLogin(user.Id, loginMode); await App.GetRequiredService<SysOnlineUserService>().SingleLogin(user.Id, loginMode);
// 生成Token令牌 // 生成Token令牌
user.TokenVersion += 1;
var tokenExpire = await _sysConfigService.GetTokenExpire(); var tokenExpire = await _sysConfigService.GetTokenExpire();
var accessToken = JWTEncryption.Encrypt(new Dictionary<string, object> var accessToken = JWTEncryption.Encrypt(new Dictionary<string, object>
{ {
@ -263,7 +264,6 @@ public class SysAuthService : IDynamicApiController, ITransient
// ke.global.setAllHeader('Authorization', 'Bearer ' + ke.response.headers['access-token']); // ke.global.setAllHeader('Authorization', 'Bearer ' + ke.response.headers['access-token']);
// 更新用户登录信息 // 更新用户登录信息
user.TokenVersion += 1;
user.LastLoginIp = _httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(true); user.LastLoginIp = _httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(true);
(user.LastLoginAddress, double? longitude, double? latitude) = CommonHelper.GetIpAddress(user.LastLoginIp); (user.LastLoginAddress, double? longitude, double? latitude) = CommonHelper.GetIpAddress(user.LastLoginIp);
user.LastLoginTime = DateTime.Now; user.LastLoginTime = DateTime.Now;