feat: 完成双token刷新

This commit is contained in:
ccnetcore
2025-06-29 15:18:30 +08:00
parent d4f00eb89f
commit 6a58af8dfb
7 changed files with 344 additions and 326 deletions

View File

@@ -190,25 +190,21 @@ namespace Yi.Framework.Rbac.Domain.Managers
{
//此处优先从缓存中获取
UserRoleMenuDto output = null;
var tokenExpiresMinuteTime =
LazyServiceProvider.GetRequiredService<IOptions<JwtOptions>>().Value.ExpiresMinuteTime;
var tokenExpiresSecondTime =
LazyServiceProvider.GetRequiredService<IOptions<JwtOptions>>().Value.ExpiresSecondTime;
var cacheData = await _userCache.GetOrAddAsync(new UserInfoCacheKey(userId),
async () =>
{
var user = await _userRepository.GetUserAllInfoAsync(userId);
var data = EntityMapToDto(user);
//系统用户数据被重置,老前端访问重新授权
if (data is null)
{
throw new AbpAuthorizationException();
}
//data.Menus.Clear();
output = data;
output = data ?? throw new AbpAuthorizationException();
return new UserInfoCacheItem(data);
},
() => new DistributedCacheEntryOptions
{ AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(tokenExpiresMinuteTime) });
{ AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(tokenExpiresSecondTime) });
if (cacheData is not null)
{