refactor: consolidate project structure by migrating authentication, identity, and shared UI components while removing legacy Web Client files.
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
@page "/account/login"
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using NexusReader.UI.Shared.Services
|
||||
@inject IIdentityService IdentityService
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<div class="login-container">
|
||||
<div class="login-card">
|
||||
<div class="login-header">
|
||||
<h1>NEXUS<span>AI</span></h1>
|
||||
<p>Welcome back, Reader.</p>
|
||||
</div>
|
||||
|
||||
<EditForm Model="@_loginModel" OnValidSubmit="HandleLogin">
|
||||
<DataAnnotationsValidator />
|
||||
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<InputText id="email" @bind-Value="_loginModel.Email" class="form-control" placeholder="reader@nexus.ai" />
|
||||
<ValidationMessage For="@(() => _loginModel.Email)" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<InputText id="password" type="password" @bind-Value="_loginModel.Password" class="form-control" placeholder="••••••••" />
|
||||
<ValidationMessage For="@(() => _loginModel.Password)" />
|
||||
</div>
|
||||
|
||||
<div class="form-options">
|
||||
<div class="remember-me">
|
||||
<InputCheckbox id="remember" @bind-Value="_loginModel.RememberMe" />
|
||||
<label for="remember">Remember me</label>
|
||||
</div>
|
||||
<a href="/account/forgot-password" class="forgot-link">Forgot password?</a>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_errorMessage))
|
||||
{
|
||||
<div class="error-banner">
|
||||
@_errorMessage
|
||||
</div>
|
||||
}
|
||||
|
||||
<button type="submit" class="btn-login" disabled="@_isSubmitting">
|
||||
@if (_isSubmitting)
|
||||
{
|
||||
<span class="spinner"></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Login</span>
|
||||
}
|
||||
</button>
|
||||
|
||||
<div class="separator">
|
||||
<span>OR</span>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn-google" @onclick="HandleGoogleLogin">
|
||||
<img src="https://www.gstatic.com/images/branding/product/1x/gsa_512dp.png" alt="Google" />
|
||||
Continue with Google
|
||||
</button>
|
||||
</EditForm>
|
||||
|
||||
<div class="login-footer">
|
||||
<p>Don't have an account? <a href="/account/register">Create one</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private LoginModel _loginModel = new();
|
||||
private string? _errorMessage;
|
||||
private bool _isSubmitting;
|
||||
|
||||
private async Task HandleLogin()
|
||||
{
|
||||
_isSubmitting = true;
|
||||
_errorMessage = null;
|
||||
|
||||
try
|
||||
{
|
||||
var success = await IdentityService.LoginAsync(_loginModel.Email, _loginModel.Password);
|
||||
if (success)
|
||||
{
|
||||
NavigationManager.NavigateTo("/");
|
||||
}
|
||||
else
|
||||
{
|
||||
_errorMessage = "Invalid email or password.";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_errorMessage = "An error occurred during login. Please try again.";
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isSubmitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleGoogleLogin()
|
||||
{
|
||||
// Redirect to external login endpoint
|
||||
NavigationManager.NavigateTo("identity/login/google", forceLoad: true);
|
||||
}
|
||||
|
||||
public class LoginModel
|
||||
{
|
||||
[System.ComponentModel.DataAnnotations.Required]
|
||||
[System.ComponentModel.DataAnnotations.EmailAddress]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
public bool RememberMe { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user