Add authentication support with login/logout UI
- Introduced AuthService, IAuthApiClient, and AuthApiClient for managing authentication state and API calls (login, logout, session restore). - Added Login.razor and LoginLayout.razor for the login page, including styling and logic. - MainLayout.razor now checks authentication on load, restores sessions from sessionStorage, and redirects to /login if unauthenticated. Displays username and logout button when logged in. - Implemented JS interop (authStorage) for persisting authentication info in sessionStorage. - Registered AuthService, CookieContainer, and API clients in Program.cs to share cookies and support authentication. - Updated AppSettings and appsettings files to support separate ApiBaseUrl and DataApiBaseUrl. - Minor CSS improvements for username display in the top bar.
This commit is contained in:
8
DbFirst.BlazorWebApp/Services/IAuthApiClient.cs
Normal file
8
DbFirst.BlazorWebApp/Services/IAuthApiClient.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace DbFirst.BlazorWebApp.Services;
|
||||
|
||||
public interface IAuthApiClient
|
||||
{
|
||||
Task<bool> LoginAsync(string username, string password, CancellationToken ct = default);
|
||||
Task LogoutAsync(CancellationToken ct = default);
|
||||
Task<bool> RestoreAsync(string username, string rawCookieHeader, CancellationToken ct = default);
|
||||
}
|
||||
Reference in New Issue
Block a user