Debug and fix called url

This commit is contained in:
2026-01-27 22:25:43 +01:00
parent 803a9f86e1
commit 8838fcd65c
2 changed files with 10 additions and 4 deletions

View File

@@ -6,7 +6,7 @@
<title>Register</title>
<EditForm Model="user" OnValidSubmit="HandleRegistration" FormName="registerForm">
<EditForm Model="user" OnValidSubmit="HandleRegistration" OnInvalidSubmit="HandleInvalidSubmit" FormName="registerForm">
<DataAnnotationsValidator/>
<div class="d-flex justify-content-center align-items-center">
<div class="col-md-4 p-5 shadow-sm border rounded-3">
@@ -52,11 +52,17 @@
private string messageCssClass = string.Empty;
private string errorMessage = string.Empty;
async void HandleRegistration()
async Task HandleRegistration()
{
var response = await _http.PostAsJsonAsync("api/auth/register", user);
var response = await _http.PostAsJsonAsync("/api/register", user);
var result = await response.Content.ReadFromJsonAsync<ServiceResponse<int>>();
message = result.Message;
messageCssClass = result.Success ? "text-success" : "text-danger";
}
async Task HandleInvalidSubmit()
{
message = "Data annotations validation failed.";
messageCssClass = "text-danger";
}
}

View File

@@ -24,7 +24,7 @@ app.UseHttpsRedirection();
app.UseAntiforgery();
app.MapPost("/register", async (UserRegister request, IAuthService authService) =>
app.MapPost("/api/register", async (UserRegister request, IAuthService authService) =>
await authService.Register(request.Email, request.Password));
app.MapStaticAssets();