forked from baron/baron-sso
[userfront] source 개념삭제. redirect 동작 정리
This commit is contained in:
@@ -61,10 +61,11 @@ void implSendLoginSuccess(String token) {
|
||||
}
|
||||
|
||||
final message = {'type': 'LOGIN_SUCCESS', 'token': effectiveToken};
|
||||
final opener = html.window.opener;
|
||||
|
||||
if (html.window.opener != null) {
|
||||
if (opener != null) {
|
||||
try {
|
||||
html.window.opener!.postMessage(message, '*');
|
||||
opener.postMessage(message, '*');
|
||||
debugPrint('Sent login success message to opener');
|
||||
} catch (e) {
|
||||
debugPrint('Failed to postMessage: $e');
|
||||
@@ -72,22 +73,20 @@ void implSendLoginSuccess(String token) {
|
||||
|
||||
// Close the popup after a short delay to ensure message sending
|
||||
Timer(const Duration(milliseconds: 500), () {
|
||||
html.window.close();
|
||||
try {
|
||||
html.window.close();
|
||||
} catch (e) {
|
||||
debugPrint('Failed to close window: $e');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Should not happen given isPopup check, but as fallback:
|
||||
debugPrint('No opener found during popup flow.');
|
||||
return;
|
||||
}
|
||||
|
||||
// No opener and no redirect: fall back to local navigation
|
||||
debugPrint('No opener found. Redirecting to /.');
|
||||
html.window.location.href = '/';
|
||||
}
|
||||
|
||||
bool implIsPopup() {
|
||||
if (html.window.opener != null) return true;
|
||||
|
||||
// Fallback: Check query parameters for integration source
|
||||
final uri = Uri.base;
|
||||
if (uri.queryParameters['source'] == 'adminfront') return true;
|
||||
|
||||
// Manual parse fallback for cases where Uri.base might miss params due to hash routing
|
||||
final search = html.window.location.search;
|
||||
return search != null && search.contains('source=adminfront');
|
||||
return html.window.opener != null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user