/// <summary> /// Zwraca informacje o zalogowanym użytkowniku /// </summary> /// <returns> /// Informacje o zalogowanym użytkowniku /// </returns> [HttpGet("auth/self")] // [Authorize(AuthenticationSchemes = "Bearer")] [AllowAnonymous] public async Task<IActionResult> GetSelfInfoAsync() { var user = User; var claims = user.Claims; _logger.LogInformation("User {Username} requested self info", user.FindFirstValue(ClaimTypes.Name)); _logger.LogDebug("User {Username} requested self info with claims: {Claims}", user.FindFirstValue(ClaimTypes.Name), claims); var userId = user.FindFirstValue(ClaimTypes.NameIdentifier) ?? throw new UnauthorizedAccessException("User not found"); var userIdAsGuid = Guid.Parse(userId); return Ok(new UserJwtInfoResponseDTO() { Username = user.FindFirstValue(ClaimTypes.Name), Email = user.FindFirstValue(ClaimTypes.Email), Role = user.FindFirstValue(ClaimTypes.Role) }); }