forked from baron/baron-sso
fix(userfront): restore web auth redirect variables after merge regression
This commit is contained in:
@@ -3,16 +3,32 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:html' as html;
|
import 'dart:html' as html;
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'auth_token_store.dart';
|
||||||
|
|
||||||
void implSendLoginSuccess(String token) {
|
void implSendLoginSuccess(String token) {
|
||||||
final message = {'type': 'LOGIN_SUCCESS', 'token': token};
|
var effectiveToken = token;
|
||||||
|
if (effectiveToken.isEmpty) {
|
||||||
if (html.window.opener != null) {
|
effectiveToken = AuthTokenStore.getToken() ?? "";
|
||||||
try {
|
}
|
||||||
html.window.opener!.postMessage(message, '*');
|
|
||||||
debugPrint('Sent login success message to opener');
|
final fullUrl = html.window.location.href;
|
||||||
} catch (e) {
|
final uri = Uri.base;
|
||||||
debugPrint('Failed to postMessage: $e');
|
|
||||||
|
// Try to find redirect_uri from standard parsing first, then manual string search
|
||||||
|
String? redirectUri =
|
||||||
|
uri.queryParameters['redirect_uri'] ??
|
||||||
|
uri.queryParameters['redirect_url'];
|
||||||
|
|
||||||
|
if (redirectUri == null) {
|
||||||
|
// Manual fallback for cases where Uri.base misses params
|
||||||
|
final searchParams = html.window.location.search;
|
||||||
|
if (searchParams != null && searchParams.isNotEmpty) {
|
||||||
|
final sUri = Uri.parse(
|
||||||
|
'?${searchParams.startsWith('?') ? searchParams.substring(1) : searchParams}',
|
||||||
|
);
|
||||||
|
redirectUri =
|
||||||
|
sUri.queryParameters['redirect_uri'] ??
|
||||||
|
sUri.queryParameters['redirect_url'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,9 +79,7 @@ void implSendLoginSuccess(String token) {
|
|||||||
debugPrint('Failed to close window: $e');
|
debugPrint('Failed to close window: $e');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
return;
|
||||||
// Should not happen given isPopup check, but as fallback:
|
|
||||||
debugPrint('No opener found during popup flow.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No opener and no redirect: fall back to local navigation
|
// No opener and no redirect: fall back to local navigation
|
||||||
|
|||||||
Reference in New Issue
Block a user