From e9f203d747e895c4cc4d8c636781651d7f162209 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Mon, 11 Dec 2023 11:11:06 -0800 Subject: [PATCH] client/web: open new window if iframed Previously, we were only breaking out of iframes when accessing the login client over a local IP address (where viewerIdentity is not set). We need to also handle the case where the user is accessing the login client over the Tailscale IP, and similarly break out of the iframe when logging into the management client. Updates #10261 Signed-off-by: Will Norris --- client/web/src/components/login-toggle.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/web/src/components/login-toggle.tsx b/client/web/src/components/login-toggle.tsx index 011aa2f8b..a1dbd3c95 100644 --- a/client/web/src/components/login-toggle.tsx +++ b/client/web/src/components/login-toggle.tsx @@ -126,7 +126,14 @@ function LoginPopoverContent({ const handleSignInClick = useCallback(() => { if (auth.viewerIdentity) { - newSession() + if (window.self !== window.top) { + // if we're inside an iframe, start session in new window + let url = new URL(window.location.href) + url.searchParams.set("check", "now") + window.open(url, "_blank") + } else { + newSession() + } } else { // Must be connected over Tailscale to log in. // Send user to Tailscale IP and start check mode