Add project files.

This commit is contained in:
rossmill76 committed 2026-03-01 18:17:42 +00:00
1 parent fd9f318d6a
commit 0ce077ec11
98 files changed
+65707

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
@page "/login"
@layout AuthLayout
@using Microsoft.AspNetCore.Identity
@inject SignInManager<ApplicationUser> SignInManager
@inject NavigationManager Navigation
<PageTitle>Budgeteer — Sign In</PageTitle>
<h3 class="text-center mb-4">Sign In</h3>
<EditForm Model="Model" OnValidSubmit="HandleLogin" FormName="login">
<DataAnnotationsValidator />
@if (!string.IsNullOrEmpty(errorMessage))
{
<div class="alert alert-danger">@errorMessage</div>
}
<div class="mb-3">
<label class="form-label">Email</label>
<InputText @bind-Value="Model.Email" class="form-control" placeholder="you@example.com" />
<ValidationMessage For="() => Model.Email" />
</div>
<div class="mb-3">
<label class="form-label">Password</label>
<InputText @bind-Value="Model.Password" type="password" class="form-control" />
<ValidationMessage For="() => Model.Password" />
</div>
<button type="submit" class="btn btn-primary w-100">Sign In</button>
</EditForm>
<p class="text-center mt-3">
Don't have an account? <a href="/register">Register</a>
</p>
@code {
[SupplyParameterFromForm]
private LoginModel Model { get; set; } = new();
private string? errorMessage;
private async Task HandleLogin()
{
errorMessage = null;
var result = await SignInManager.PasswordSignInAsync(
Model.Email, Model.Password, isPersistent: false, lockoutOnFailure: false);
if (result.Succeeded)
{
Navigation.NavigateTo("/", forceLoad: true);
}
else
{
errorMessage = "Invalid email or password.";
}
}
private sealed class LoginModel
{
[System.ComponentModel.DataAnnotations.Required(ErrorMessage = "Email is required")]
[System.ComponentModel.DataAnnotations.EmailAddress]
public string Email { get; set; } = string.Empty;
[System.ComponentModel.DataAnnotations.Required(ErrorMessage = "Password is required")]
public string Password { get; set; } = string.Empty;
}
}