@page "/account/login" @using TrueCV.Web.Components.Layout @layout MainLayout @rendermode InteractiveServer @using Microsoft.AspNetCore.Identity @using TrueCV.Infrastructure.Identity @inject SignInManager SignInManager @inject NavigationManager NavigationManager Login - TrueCV

Welcome Back

Sign in to your TrueCV account

@if (!string.IsNullOrEmpty(_errorMessage)) { }

Don't have an account? Create one

@code { private LoginModel _model = new(); private bool _isLoading; private string? _errorMessage; [SupplyParameterFromQuery] public string? ReturnUrl { get; set; } private async Task HandleLogin() { _isLoading = true; _errorMessage = null; try { var result = await SignInManager.PasswordSignInAsync( _model.Email, _model.Password, _model.RememberMe, lockoutOnFailure: false); if (result.Succeeded) { var returnUrl = string.IsNullOrEmpty(ReturnUrl) ? "/dashboard" : ReturnUrl; NavigationManager.NavigateTo(returnUrl, forceLoad: true); } else if (result.IsLockedOut) { _errorMessage = "This account has been locked out. Please try again later."; } else if (result.IsNotAllowed) { _errorMessage = "This account is not allowed to sign in."; } else { _errorMessage = "Invalid email or password."; } } catch (Exception ex) { _errorMessage = $"An error occurred: {ex.Message}"; } finally { _isLoading = false; } } private sealed class LoginModel { [System.ComponentModel.DataAnnotations.Required(ErrorMessage = "Email is required")] [System.ComponentModel.DataAnnotations.EmailAddress(ErrorMessage = "Invalid email format")] public string Email { get; set; } = string.Empty; [System.ComponentModel.DataAnnotations.Required(ErrorMessage = "Password is required")] public string Password { get; set; } = string.Empty; public bool RememberMe { get; set; } } }