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:
111
DbFirst.BlazorWebApp/Components/Pages/Login.razor.css
Normal file
111
DbFirst.BlazorWebApp/Components/Pages/Login.razor.css
Normal file
@@ -0,0 +1,111 @@
|
||||
.login-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: calc(100vh - 2rem);
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
padding: 2rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--band-editor-border, #dee2e6);
|
||||
background-color: var(--band-editor-bg, #fff);
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.login-header {
|
||||
text-align: center;
|
||||
margin-bottom: 1.75rem;
|
||||
}
|
||||
|
||||
.login-brand {
|
||||
font-size: 1.8rem;
|
||||
font-weight: 700;
|
||||
color: #1b6ec2;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.login-subtitle {
|
||||
margin-top: 0.35rem;
|
||||
margin-bottom: 0;
|
||||
font-size: 0.9rem;
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.login-field {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.login-label {
|
||||
display: block;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
margin-bottom: 0.3rem;
|
||||
}
|
||||
|
||||
.login-actions {
|
||||
margin-top: 1.25rem;
|
||||
}
|
||||
|
||||
/* Gemeinsamer Stil für Text- und Passwort-Eingabefelder */
|
||||
.login-text-input {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 2.25rem;
|
||||
padding: 0.25rem 0.65rem;
|
||||
font-size: 1rem;
|
||||
font-family: inherit;
|
||||
line-height: 1.5;
|
||||
color: inherit;
|
||||
background-color: transparent;
|
||||
border: 1px solid #ced4da;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
outline: none;
|
||||
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
||||
}
|
||||
|
||||
.login-text-input:focus {
|
||||
border-color: #86b7fe;
|
||||
box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
|
||||
}
|
||||
|
||||
/* Submit-Button */
|
||||
.login-submit-btn {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 0.45rem 1rem;
|
||||
font-size: 1rem;
|
||||
font-family: inherit;
|
||||
font-weight: 500;
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border: 1px solid #1861ac;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
|
||||
}
|
||||
|
||||
.login-submit-btn:hover:not(:disabled) {
|
||||
background-color: #1558a0;
|
||||
border-color: #1456a0;
|
||||
}
|
||||
|
||||
.login-submit-btn:disabled {
|
||||
opacity: 0.65;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* Dark-Mode */
|
||||
.app-dark .login-text-input {
|
||||
border-color: #555;
|
||||
color: #e8e8e8;
|
||||
background-color: #2d2d2d;
|
||||
}
|
||||
|
||||
.app-dark .login-text-input:focus {
|
||||
border-color: #6cb6ff;
|
||||
box-shadow: 0 0 0 0.2rem rgba(108, 182, 255, 0.25);
|
||||
}
|
||||
Reference in New Issue
Block a user