fix(frontend): hide logout outside local auth
This commit is contained in:
@@ -17,14 +17,20 @@ import { Button } from "../components/ui/button";
|
||||
|
||||
type GateStatus = "loading" | "login" | "authenticated" | "forbidden" | "unavailable";
|
||||
|
||||
function AuthenticatedContent({ onExpired }: { onExpired: () => void }) {
|
||||
function AuthenticatedContent({
|
||||
canLogout,
|
||||
onExpired,
|
||||
}: {
|
||||
canLogout: boolean;
|
||||
onExpired: () => void;
|
||||
}) {
|
||||
const user = useAuthUser();
|
||||
const authGeneration = useAuthGeneration();
|
||||
useEffect(() => {
|
||||
if (!user) onExpired();
|
||||
}, [onExpired, user]);
|
||||
return user
|
||||
? <AppShell key={`${user.issuer}:${user.subject}:${authGeneration}`} />
|
||||
? <AppShell key={`${user.issuer}:${user.subject}:${authGeneration}`} canLogout={canLogout} />
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -77,7 +83,12 @@ export function AuthGate() {
|
||||
}
|
||||
|
||||
if (status === "authenticated") {
|
||||
return <AuthenticatedContent onExpired={() => setStatus("login")} />;
|
||||
return (
|
||||
<AuthenticatedContent
|
||||
canLogout={config?.mode === "local"}
|
||||
onExpired={() => setStatus("login")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (status === "unavailable") {
|
||||
|
||||
Reference in New Issue
Block a user