Refactor authentication components for modularity

Replaced `LoginForm` with a more extensible `AuthForm` and `AuthScreen`, enabling support for multiple auth strategies (e.g., OAuth) and improved reusability. Updated imports, routes, and configurations accordingly.
This commit is contained in:
dswbx
2025-01-09 10:20:28 +01:00
parent fcab042e88
commit 5c7bfeab8f
11 changed files with 237 additions and 146 deletions

View File

@@ -144,7 +144,7 @@ export function Header({ hasSidebar = true }) {
}
function UserMenu() {
const { adminOverride } = useBknd();
const { adminOverride, config } = useBknd();
const auth = useAuth();
const [navigate] = useNavigate();
const { logout_route } = useBkndWindowContext();
@@ -163,10 +163,16 @@ function UserMenu() {
{ label: "Settings", onClick: () => navigate("/settings"), icon: IconSettings }
];
if (!auth.user) {
items.push({ label: "Login", onClick: handleLogin, icon: IconUser });
} else {
items.push({ label: `Logout ${auth.user.email}`, onClick: handleLogout, icon: IconKeyOff });
if (config.auth.enabled) {
if (!auth.user) {
items.push({ label: "Login", onClick: handleLogin, icon: IconUser });
} else {
items.push({
label: `Logout ${auth.user.email}`,
onClick: handleLogout,
icon: IconKeyOff
});
}
}
if (!adminOverride) {