fix(web-client): split DisplayName into FirstName/LastName for registration

This commit is contained in:
Ho Ngoc Hai
2026-02-28 04:03:04 +07:00
parent 1caaf5e1e4
commit 1e211dec27
6 changed files with 62 additions and 22 deletions

View File

@@ -50,19 +50,22 @@ public class AuthService
{
try
{
// EN: Build payload with FirstName/LastName from DisplayName (IAM requires these)
// VI: Tạo payload với FirstName/LastName từ DisplayName (IAM yêu cầu)
var parts = (dto.DisplayName ?? "User").Trim().Split(' ', 2);
// EN: Build payload with FirstName/LastName from form (IAM requires these)
// VI: Tạo payload với FirstName/LastName từ form (IAM yêu cầu)
var payload = new
{
dto.Email,
dto.Password,
FirstName = parts[0],
LastName = parts.Length > 1 ? parts[1] : parts[0],
DisplayName = dto.DisplayName
dto.FirstName,
dto.LastName
};
var response = await _http.PostAsJsonAsync("/api/auth/register", payload);
// EN: Use PascalCase serialization to match backend RegisterUserCommand record params
// VI: Dùng PascalCase serialization để khớp với record params backend
var jsonOptions = new JsonSerializerOptions { PropertyNamingPolicy = null };
var jsonContent = JsonContent.Create(payload, options: jsonOptions);
var response = await _http.PostAsync("/api/auth/register", jsonContent);
if (response.IsSuccessStatusCode)
{
return (true, null);