From 237c6c44cd8b4f39798d3d4f61baa1af6a041af9 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Wed, 1 Nov 2023 10:35:46 -0700 Subject: [PATCH] client/web: call /api/auth before rendering any client views For now this is effectively a noop, since only the ManagementClientView uses the auth data. That will change soon. Updates tailscale/corp#14335 Signed-off-by: Will Norris --- client/web/src/components/app.tsx | 30 ++++++++++-------------------- client/web/web.go | 10 +++++++++- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/client/web/src/components/app.tsx b/client/web/src/components/app.tsx index cf06ee724..8b10ae475 100644 --- a/client/web/src/components/app.tsx +++ b/client/web/src/components/app.tsx @@ -4,25 +4,29 @@ import LegacyClientView from "src/components/views/legacy-client-view" import LoginClientView from "src/components/views/login-client-view" import ReadonlyClientView from "src/components/views/readonly-client-view" import useAuth from "src/hooks/auth" -import useNodeData, { NodeData } from "src/hooks/node-data" +import useNodeData from "src/hooks/node-data" import ManagementClientView from "./views/management-client-view" export default function App() { const { data, refreshData, updateNode } = useNodeData() + const { data: auth, loading: loadingAuth, waitOnAuth } = useAuth() return (
- {!data ? ( -
Loading...
// TODO(sonia): add a loading view + {!data || loadingAuth ? ( +
Loading...
// TODO(sonia): add a loading view ) : data?.Status === "NeedsLogin" || data?.Status === "NoState" ? ( // Client not on a tailnet, render login. updateNode({ Reauthenticate: true })} /> + ) : data.DebugMode === "full" && auth?.ok ? ( + // Render new client interface in management mode. + ) : data.DebugMode === "login" || data.DebugMode === "full" ? ( - // Render new client interface. - + // Render new client interface in readonly mode. + ) : ( // Render legacy client interface. )} - {data &&
} + {data && !loadingAuth &&
}
) } -function WebClient(props: NodeData) { - const { data: auth, loading: loadingAuth, waitOnAuth } = useAuth() - - if (loadingAuth) { - return
Loading...
- } - - return props.DebugMode === "full" && auth?.ok ? ( - - ) : ( - - ) -} - export function Footer(props: { licensesURL: string; className?: string }) { return (