MCPcopy Create free account
hub / github.com/GmpABR/NexusFlow / GetUserId

Method GetUserId

backend/Controllers/TasksController.cs:359–377  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected