1
0
forked from baron/baron-sso

[userfront] source 개념삭제. redirect 동작 정리

This commit is contained in:
Lectom C Han
2026-02-12 11:41:16 +09:00
parent 5bdb08d673
commit 66106f20f6
3 changed files with 22 additions and 18 deletions

View File

@@ -7,7 +7,7 @@ COPY . .
# Get dependencies and build for web
RUN flutter pub get
RUN touch .env
RUN flutter build web --release --no-tree-shake-icons
RUN flutter build web --wasm --release --no-tree-shake-icons
# Stage 2: Serve with Nginx
FROM nginx:alpine

View File

@@ -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;
}

View File

@@ -1149,8 +1149,13 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
}
}
if (WebAuthIntegration.isPopup() ||
(_redirectUrl != null && _redirectUrl!.isNotEmpty)) {
final uri = Uri.base;
final redirectParam =
uri.queryParameters['redirect_uri'] ?? uri.queryParameters['redirect_url'];
final hasRedirectParam =
redirectParam != null && redirectParam.isNotEmpty;
if (WebAuthIntegration.isPopup() || hasRedirectParam) {
debugPrint(
"[Auth] External integration detected (popup or redirect). Notifying...",
);