This commit is contained in:
2026-03-30 11:07:30 +08:00
parent 2c44b3a4b2
commit d4a8e71733
74 changed files with 1751 additions and 421 deletions

View File

@@ -41,13 +41,13 @@ public class ClaimsService : IClaimsService
return claimsIdentity;
}
public int GetCurrentUserId()
public int? GetCurrentUserId()
{
var currUserId = _httpContextAccessor.HttpContext
?.User.FindFirstValue(JwtRegisteredClaimNames.Sub);
if (string.IsNullOrWhiteSpace(currUserId))
throw new InvalidOperationException("在错误的位置获取当前登录用户");
return null;
return Convert.ToInt32(currUserId);
}