Refactor authentication system to use MongoDB
Some checks failed
Publish Container / publish (push) Has been cancelled
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:
parent
7a919491d2
commit
7029e374cc
64 changed files with 338 additions and 3556 deletions
46
Components/Pages/Login.razor
Normal file
46
Components/Pages/Login.razor
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
@page "/login"
|
||||
@attribute [AllowAnonymous]
|
||||
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Components
|
||||
|
||||
<PageTitle>Login</PageTitle>
|
||||
|
||||
<h1>Login</h1>
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(Error))
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">@Error</div>
|
||||
}
|
||||
|
||||
<form method="post" action="/login" class="d-flex flex-column gap-3" style="max-width: 420px;">
|
||||
<div>
|
||||
<label for="email" class="form-label">Email</label>
|
||||
<input id="email" name="email" value="@Email" autocomplete="username" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input id="password" name="password" type="password" autocomplete="current-password" class="form-control" required />
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="returnUrl" value="@SafeReturnUrl" />
|
||||
|
||||
<button type="submit" class="btn btn-primary">Sign in</button>
|
||||
</form>
|
||||
|
||||
@code {
|
||||
[SupplyParameterFromQuery]
|
||||
public string? ReturnUrl { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
public string? Error { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
public string? Email { get; set; }
|
||||
|
||||
private string SafeReturnUrl =>
|
||||
string.IsNullOrWhiteSpace(ReturnUrl) || !Uri.IsWellFormedUriString(ReturnUrl, UriKind.Relative)
|
||||
? "/"
|
||||
: ReturnUrl;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue