fix(users): Handle null values for email and status in UserDto

- Updated the UsersController to ensure that the Email field defaults to an empty string if null, and the Status field defaults to "Unknown" if not set. This improves the robustness of the user data returned in API responses.
This commit is contained in:
Ho Ngoc Hai
2026-01-13 19:46:24 +07:00
parent 7550929f50
commit 6fa2bdbded

View File

@@ -118,11 +118,11 @@ public class UsersController : ControllerBase
return Ok(ApiResponse<UserDto>.Ok(new UserDto
{
Id = result.Id,
Email = result.Email,
Email = result.Email ?? string.Empty,
FirstName = result.FirstName,
LastName = result.LastName,
FullName = result.FullName,
Status = result.Status.Name,
Status = result.Status?.Name ?? "Unknown",
CreatedAt = result.CreatedAt,
LastLoginAt = result.LastLoginAt
}));