This commit is contained in:
2026-01-27 22:36:52 +01:00
parent 8838fcd65c
commit a74065f768

View File

@@ -13,24 +13,28 @@
<h2 class="text-center mb-4 text-primary">Register Form</h2> <h2 class="text-center mb-4 text-primary">Register Form</h2>
<div class="mb-3"> <div class="mb-3">
<label for="email" class="form-label">Email address</label> <label for="email" class="form-label">Email address</label>
<InputText type="email" @bind-Value="user.Email" class="form-control border border-primary" id="email" aria-describedby="email"/> <InputText type="email" @bind-Value="user.Email" class="form-control border border-primary" id="email"
aria-describedby="email"/>
<ValidationMessage For="@(() => user.Email)"/> <ValidationMessage For="@(() => user.Email)"/>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="password" class="form-label">Password</label> <label for="password" class="form-label">Password</label>
<InputText type="password" @bind-Value="user.Password" class="form-control border border-primary" id="password" aria-describedby="password"/> <InputText type="password" @bind-Value="user.Password" class="form-control border border-primary"
id="password" aria-describedby="password"/>
<ValidationMessage For="@(() => user.Password)"/> <ValidationMessage For="@(() => user.Password)"/>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="confirmPassword" class="form-label">Confirm password</label> <label for="confirmPassword" class="form-label">Confirm password</label>
<InputText type="password" @bind-Value="user.ConfirmPassword" class="form-control border border-primary" id="confirmPassword" aria-describedby="confirmPassword"/> <InputText type="password" @bind-Value="user.ConfirmPassword" class="form-control border border-primary"
id="confirmPassword" aria-describedby="confirmPassword"/>
<ValidationMessage For="@(() => user.ConfirmPassword)"/> <ValidationMessage For="@(() => user.ConfirmPassword)"/>
</div> </div>
<div class="d-grid"> <div class="d-grid">
<button class="btn btn-primary" type="submit">Register</button> <button class="btn btn-primary" type="submit">Register</button>
</div> </div>
<div class="mt-3"> <div class="mt-3">
<p class="mb-0 text-center">You have an account? <a href="login" class="text-primary fw-bold">Sign In</a></p> <p class="mb-0 text-center">You have an account? <a href="login" class="text-primary fw-bold">Sign
In</a></p>
</div> </div>
</div> </div>
</div> </div>
@@ -45,13 +49,16 @@
</div> </div>
@code { @code {
UserRegister user = new(); [SupplyParameterFromForm] private UserRegister user { get; set; }
HttpClient _http = new();
HttpClient _http = new() { BaseAddress = new("https://localhost:7122") };
private string message = string.Empty; private string message = string.Empty;
private string messageCssClass = string.Empty; private string messageCssClass = string.Empty;
private string errorMessage = string.Empty; private string errorMessage = string.Empty;
protected override void OnInitialized() => user ??= new();
async Task HandleRegistration() async Task HandleRegistration()
{ {
var response = await _http.PostAsJsonAsync("/api/register", user); var response = await _http.PostAsJsonAsync("/api/register", user);
@@ -65,4 +72,5 @@
message = "Data annotations validation failed."; message = "Data annotations validation failed.";
messageCssClass = "text-danger"; messageCssClass = "text-danger";
} }
} }