forked from baron/baron-sso
자식 창 로그인 우선순위 조정
This commit is contained in:
@@ -391,22 +391,27 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
|||||||
details: "User logged in via Baron SSO",
|
details: "User logged in via Baron SSO",
|
||||||
);
|
);
|
||||||
|
|
||||||
// 1. Handle Redirect Flow (Redirect to another app)
|
// 1. Handle Popup Flow (Highest Priority for child windows)
|
||||||
if (_redirectUrl != null && _redirectUrl!.isNotEmpty) {
|
// If opened as a popup (has opener), we notify and try to close.
|
||||||
final target = "$_redirectUrl?token=$token";
|
|
||||||
launchUrlString(target, webOnlyWindowName: '_self');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Handle Popup Flow (Send message to opener)
|
|
||||||
if (WebAuthIntegration.isPopup()) {
|
if (WebAuthIntegration.isPopup()) {
|
||||||
|
debugPrint("[Auth] Popup detected. Notifying opener and attempting to close.");
|
||||||
WebAuthIntegration.sendLoginSuccess(token);
|
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.
|
// 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Standalone mode: Go to dashboard
|
// 3. Standalone mode / Fallback
|
||||||
// We call notify() to update the router's state, and go() to ensure navigation.
|
// 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();
|
AuthNotifier.instance.notify();
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
context.go('/');
|
context.go('/');
|
||||||
|
|||||||
Reference in New Issue
Block a user