Refactor authentication system to use MongoDB
Some checks failed
Publish Container / publish (push) Has been cancelled

- Removed Entity Framework Core identity schema and related migrations.
- Introduced MongoDB-based authentication service with user seeding functionality.
- Updated Program.cs to configure authentication and authorization using cookies.
- Created new Login.razor component for user login interface.
- Added RedirectToLogin component for handling unauthorized access.
- Updated Dockerfile and docker-compose files for development and production environments.
- Removed SQLite connection strings and related configurations.
- Added MongoDB connection settings in appsettings.json and Docker configurations.
- Implemented IMongoAuthService interface and MongoAuthService class for user management.
- Created MongoAuthUser model for MongoDB user representation.
This commit is contained in:
MaddoScientisto 2026-03-16 21:54:44 +01:00
commit 7029e374cc
64 changed files with 338 additions and 3556 deletions

View file

@ -1,8 +1,4 @@
@implements IDisposable
@inject NavigationManager NavigationManager
<div class="top-row ps-3 navbar navbar-dark">
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">WorkTracker</a>
</div>
@ -27,14 +23,12 @@
<AuthorizeView>
<Authorized>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Account/Manage">
<NavLink class="nav-link" href="auth">
<span class="bi bi-person-fill-nav-menu" aria-hidden="true"></span> @context.User.Identity?.Name
</NavLink>
</div>
<div class="nav-item px-3">
<form action="Account/Logout" method="post">
<AntiforgeryToken />
<input type="hidden" name="ReturnUrl" value="@currentUrl" />
<form action="/logout" method="post">
<button type="submit" class="nav-link">
<span class="bi bi-arrow-bar-left-nav-menu" aria-hidden="true"></span> Logout
</button>
@ -43,7 +37,7 @@
</Authorized>
<NotAuthorized>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Account/Login">
<NavLink class="nav-link" href="login">
<span class="bi bi-person-badge-nav-menu" aria-hidden="true"></span> Login
</NavLink>
</div>
@ -52,24 +46,4 @@
</nav>
</div>
@code {
private string? currentUrl;
protected override void OnInitialized()
{
currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
NavigationManager.LocationChanged += OnLocationChanged;
}
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
{
currentUrl = NavigationManager.ToBaseRelativePath(e.Location);
StateHasChanged();
}
public void Dispose()
{
NavigationManager.LocationChanged -= OnLocationChanged;
}
}