feat: implement identity authentication, authorization policies, and MAUI platform support with Docker orchestration

This commit is contained in:
2026-04-29 20:37:41 +02:00
parent 10efed0369
commit 0210611edf
55 changed files with 2359 additions and 949 deletions
@@ -1,58 +1,70 @@
@page "/account/register"
@layout AuthLayout
@attribute [AllowAnonymous]
@using Microsoft.AspNetCore.Components.Forms
@using NexusReader.UI.Shared.Services
@using NexusReader.UI.Shared.Components.Atoms
@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>Join the future of reading.</p>
<div class="login-page-container">
<div class="mesh-bg"></div>
<div class="auth-card">
<div class="auth-header">
<div class="logo-box">
<NexusIcon Name="robot" Size="48" />
</div>
<h1 class="app-name">Nexus <span>Reader</span></h1>
<p class="auth-subtitle">Utwórz nowe konto</p>
</div>
<EditForm Model="@_registerModel" OnValidSubmit="HandleRegister">
<EditForm Model="@_registerModel" OnValidSubmit="HandleRegister" class="auth-form">
<DataAnnotationsValidator />
<div class="form-group">
<label for="email">Email</label>
<InputText id="email" @bind-Value="_registerModel.Email" class="form-control" placeholder="reader@nexus.ai" />
<ValidationMessage For="@(() => _registerModel.Email)" />
<div class="field-group">
<div class="field-icon">
<NexusIcon Name="mail" Size="18" />
</div>
<InputText id="email" @bind-Value="_registerModel.Email" placeholder="E-mail" class="field-input" />
</div>
<ValidationMessage For="@(() => _registerModel.Email)" class="auth-validation" />
<div class="form-group">
<label for="password">Password</label>
<InputText id="password" type="password" @bind-Value="_registerModel.Password" class="form-control" placeholder="Min 8 chars, uppercase, digit" />
<ValidationMessage For="@(() => _registerModel.Password)" />
<div class="field-group">
<div class="field-icon">
<NexusIcon Name="lock" Size="18" />
</div>
<InputText id="password" type="password" @bind-Value="_registerModel.Password" placeholder="Hasło" class="field-input" />
</div>
<ValidationMessage For="@(() => _registerModel.Password)" class="auth-validation" />
<div class="form-group">
<label for="confirm-password">Confirm Password</label>
<InputText id="confirm-password" type="password" @bind-Value="_registerModel.ConfirmPassword" class="form-control" placeholder="••••••••" />
<ValidationMessage For="@(() => _registerModel.ConfirmPassword)" />
<div class="field-group">
<div class="field-icon">
<NexusIcon Name="lock" Size="18" />
</div>
<InputText id="confirmPassword" type="password" @bind-Value="_registerModel.ConfirmPassword" placeholder="Potwierdź hasło" class="field-input" />
</div>
<ValidationMessage For="@(() => _registerModel.ConfirmPassword)" class="auth-validation" />
@if (!string.IsNullOrEmpty(_errorMessage))
{
<div class="error-banner">
@_errorMessage
</div>
<div class="auth-error">@_errorMessage</div>
}
<button type="submit" class="btn-login" disabled="@_isSubmitting">
<button type="submit" class="btn-submit-auth" disabled="@_isSubmitting">
@if (_isSubmitting)
{
<span class="spinner"></span>
<div class="auth-loader"></div>
}
else
{
<span>Register</span>
<span>Zarejestruj się</span>
}
</button>
</EditForm>
<div class="login-footer">
<p>Already have an account? <a href="/account/login">Login here</a></p>
<div class="auth-footer">
<p class="auth-switch">Masz już konto? <a href="/account/login">Zaloguj się</a></p>
</div>
</div>
</div>
@@ -64,12 +76,6 @@
private async Task HandleRegister()
{
if (_registerModel.Password != _registerModel.ConfirmPassword)
{
_errorMessage = "Passwords do not match.";
return;
}
_isSubmitting = true;
_errorMessage = null;
@@ -78,35 +84,27 @@
var success = await IdentityService.RegisterAsync(_registerModel.Email, _registerModel.Password);
if (success)
{
// Registration successful, redirect to login
NavigationManager.NavigateTo("/account/login?registered=true");
}
else
{
_errorMessage = "Registration failed. Email might already be in use.";
var loginSuccess = await IdentityService.LoginAsync(_registerModel.Email, _registerModel.Password);
if (loginSuccess) NavigationManager.NavigateTo("/");
else NavigationManager.NavigateTo("/account/login");
}
else { _errorMessage = "Rejestracja nie powiodła się."; }
}
catch (Exception)
{
_errorMessage = "An error occurred during registration. Please try again.";
}
finally
{
_isSubmitting = false;
}
catch (Exception) { _errorMessage = "Wystąpił błąd podczas rejestracji."; }
finally { _isSubmitting = false; }
}
public class RegisterModel
{
[System.ComponentModel.DataAnnotations.Required]
[System.ComponentModel.DataAnnotations.EmailAddress]
[System.ComponentModel.DataAnnotations.Required(ErrorMessage = "E-mail jest wymagany")]
[System.ComponentModel.DataAnnotations.EmailAddress(ErrorMessage = "Nieprawidłowy e-mail")]
public string Email { get; set; } = string.Empty;
[System.ComponentModel.DataAnnotations.Required]
[System.ComponentModel.DataAnnotations.MinLength(8)]
[System.ComponentModel.DataAnnotations.Required(ErrorMessage = "Hasło jest wymagane")]
[System.ComponentModel.DataAnnotations.MinLength(8, ErrorMessage = "Minimum 8 znaków")]
public string Password { get; set; } = string.Empty;
[System.ComponentModel.DataAnnotations.Required]
[System.ComponentModel.DataAnnotations.Compare(nameof(Password), ErrorMessage = "Hasła nie są identyczne")]
public string ConfirmPassword { get; set; } = string.Empty;
}
}