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

Method GetUserId

backend/Controllers/UsersController.cs:200–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198 }
199
200 private int GetUserId()
201 {
202 var claims = User.Claims.Select(c => $"{c.Type}: {c.Value}");
203 Console.WriteLine($"[UsersController] User Claims: {string.Join(", ", claims)}");
204
205 var idClaim = User.FindFirst(ClaimTypes.NameIdentifier)?.Value
206 ?? User.FindFirst("sub")?.Value
207 ?? User.FindFirst("id")?.Value
208 ?? User.FindFirst(JwtRegisteredClaimNames.Sub)?.Value;
209
210 if (int.TryParse(idClaim, out int userId))
211 {
212 Console.WriteLine($"[UsersController] Extracted UserId: {userId}");
213 return userId;
214 }
215
216 Console.WriteLine("[UsersController] WARNING: UserId claim not found or not an integer.");
217 return 0;
218 }
219}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected