From 48568017567c28cd778f25a24d1f97dd64bb7abb Mon Sep 17 00:00:00 2001 From: chan Date: Tue, 20 Jan 2026 15:25:56 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=90=EC=8B=9D=20=EC=B0=BD=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=9A=B0=EC=84=A0=EC=88=9C=EC=9C=84=20?= =?UTF-8?q?=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/presentation/login_screen.dart | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/frontend/lib/features/auth/presentation/login_screen.dart b/frontend/lib/features/auth/presentation/login_screen.dart index 8914dc6e..df81d0a2 100644 --- a/frontend/lib/features/auth/presentation/login_screen.dart +++ b/frontend/lib/features/auth/presentation/login_screen.dart @@ -391,22 +391,27 @@ class _LoginScreenState extends ConsumerState details: "User logged in via Baron SSO", ); - // 1. Handle Redirect Flow (Redirect to another app) - if (_redirectUrl != null && _redirectUrl!.isNotEmpty) { - final target = "$_redirectUrl?token=$token"; - launchUrlString(target, webOnlyWindowName: '_self'); - return; + // 1. Handle Popup Flow (Highest Priority for child windows) + // If opened as a popup (has opener), we notify and try to close. + if (WebAuthIntegration.isPopup()) { + debugPrint("[Auth] Popup detected. Notifying opener and attempting to close."); + WebAuthIntegration.sendLoginSuccess(token); + + // We don't 'return' here to allow a fallback if window.close() is blocked, + // but in most cases WebAuthIntegration.sendLoginSuccess will close the window. + } else { + // 2. Handle Redirect Flow (Only if NOT a popup) + if (_redirectUrl != null && _redirectUrl!.isNotEmpty) { + debugPrint("[Auth] Redirecting standalone window to: $_redirectUrl"); + final target = "$_redirectUrl?token=$token"; + launchUrlString(target, webOnlyWindowName: '_self'); + return; + } } - // 2. Handle Popup Flow (Send message to opener) - if (WebAuthIntegration.isPopup()) { - WebAuthIntegration.sendLoginSuccess(token); - // If this window was truly a popup for another app, it should close now. - // If it's still here, we allow it to fall through to the dashboard. - } - - // 3. Standalone mode: Go to dashboard - // We call notify() to update the router's state, and go() to ensure navigation. + // 3. Standalone mode / Fallback + // If it's a standard login, or if a popup's window.close() was blocked by the browser. + debugPrint("[Auth] Login success. Navigating to root."); AuthNotifier.instance.notify(); if (mounted) { context.go('/');