From 74947ce459161b941a81de1e5fb157296af7cb31 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Tue, 14 Nov 2023 11:00:23 -0800 Subject: [PATCH] client/web: only trigger check mode if not authed After logging in, the `?check=now` query string is still present if it was passed. Reloading the page causes a new check mode to be triggered, even though the user has an active session. Only trigger the automatic check mode if the user is not already able to manage the device. Updates tailscale/corp#14335 Signed-off-by: Will Norris --- client/web/src/hooks/auth.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/web/src/hooks/auth.ts b/client/web/src/hooks/auth.ts index 428d6025a..0f30f18f3 100644 --- a/client/web/src/hooks/auth.ts +++ b/client/web/src/hooks/auth.ts @@ -41,6 +41,7 @@ export default function useAuth() { default: setLoading(false) } + return d }) .catch((error) => { setLoading(false) @@ -64,10 +65,14 @@ export default function useAuth() { }, []) useEffect(() => { - loadAuth() - if (new URLSearchParams(window.location.search).get("check") == "now") { - newSession() - } + loadAuth().then((d) => { + if ( + !d.canManageNode && + new URLSearchParams(window.location.search).get("check") == "now" + ) { + newSession() + } + }) }, []) return {