DeutschLernen/GermanApp/Infrastructure
Lasse Rune Hansen ef72cbea18 fix(backend/auth): Fix JWT token claim mapping for user ID
- Changed AuthService.GenerateJwtToken to use JWT standard claims:
  - JwtRegisteredClaimNames.Sub for user ID (instead of ClaimTypes.NameIdentifier)
  - JwtRegisteredClaimNames.Name for username
  - JwtRegisteredClaimNames.Email for email
  - JwtRegisteredClaimNames.UniqueName for additional username claim
  - Kept ClaimTypes.Role for role

- Updated AuthController.GetCurrentUser to use JwtRegisteredClaimNames.Sub
- Updated AdminController.DeleteUserAsync to use JwtRegisteredClaimNames.Sub

This fixes the 401 error when calling /me after login. The issue was that
tokens were being generated with ClaimTypes.NameIdentifier claim, but the
JWT middleware doesn't automatically map this to a claim that can be found
with User.FindFirst(). Using standard JWT claims (sub, name, email) ensures
proper compatibility with ASP.NET Core's JWT authentication.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-06-14 17:38:27 +02:00
..
Configuration feat(backend/ai-services): Phase 3 - Model validation and setup guide 2026-06-13 10:47:02 +02:00
Data fix(backend/auth): Fix authentication bugs 2026-06-14 16:40:01 +02:00
Services fix(backend/auth): Fix JWT token claim mapping for user ID 2026-06-14 17:38:27 +02:00