()
| 357 | } |
| 358 | |
| 359 | private int GetUserId() |
| 360 | { |
| 361 | var claims = User.Claims.Select(c => $"{c.Type}: {c.Value}"); |
| 362 | Console.WriteLine($"[TasksController] User Claims: {string.Join(", ", claims)}"); |
| 363 | |
| 364 | var idClaim = User.FindFirst(ClaimTypes.NameIdentifier)?.Value |
| 365 | ?? User.FindFirst("sub")?.Value |
| 366 | ?? User.FindFirst("id")?.Value |
| 367 | ?? User.FindFirst(JwtRegisteredClaimNames.Sub)?.Value; |
| 368 | |
| 369 | if (int.TryParse(idClaim, out int userId)) |
| 370 | { |
| 371 | Console.WriteLine($"[TasksController] Extracted UserId: {userId}"); |
| 372 | return userId; |
| 373 | } |
| 374 | |
| 375 | Console.WriteLine("[TasksController] WARNING: UserId claim not found or not an integer."); |
| 376 | return 0; |
| 377 | } |
| 378 | } |
nothing calls this directly
no outgoing calls
no test coverage detected