🐛 Fix oidc callback

This commit is contained in:
2025-11-16 18:38:36 +08:00
parent a8617a5040
commit e7e3bfcadf
3 changed files with 14 additions and 6 deletions

View File

@@ -15,6 +15,7 @@ import 'package:island/pods/websocket.dart';
import 'package:island/screens/account/me/profile_update.dart';
import 'package:island/services/event_bus.dart';
import 'package:island/services/notify.dart';
import 'package:island/services/udid.dart';
import 'package:island/widgets/alert.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:styled_widget/styled_widget.dart';
@@ -180,7 +181,7 @@ class CreateAccountContent extends HookConsumerWidget {
} else {
// Existing user, switch to login
showSnackBar('Account already exists. Redirecting to login.');
context.goNamed('login');
if (context.mounted) context.goNamed('login');
}
} catch (err) {
showErrorAlert(err);
@@ -192,10 +193,15 @@ class CreateAccountContent extends HookConsumerWidget {
Future<void> withOidc(String provider) async {
waitingForOidc.value = true;
final serverUrl = ref.watch(serverUrlProvider);
final deviceId = await getUdid();
final url =
Uri.parse('$serverUrl/pass/auth/login/${provider.toLowerCase()}')
.replace(
queryParameters: {'redirect_uri': 'solian://auth/callback'},
queryParameters: {
'returnUrl': 'solian://auth/callback',
'deviceId': deviceId,
'flow': 'login',
},
)
.toString();
final isLaunched = await launchUrlString(

View File

@@ -653,8 +653,9 @@ class _LoginLookupScreen extends HookConsumerWidget {
final token = ref.watch(tokenProvider);
final deviceId = await getUdid();
final queryParams = <String, String>{
'redirect_uri': 'solian://auth/callback',
'device_id': deviceId,
'returnUrl': 'solian://auth/callback',
'deviceId': deviceId,
'flow': 'login',
};
if (token?.token != null) {
queryParams['token'] = token!.token;

View File

@@ -116,8 +116,10 @@ class _AppWrapperState extends ConsumerState<AppWrapper>
}
void _handleDeepLink(Uri uri, WidgetRef ref) {
String path = '/${uri.host}${uri.path}';
// Special handling for OIDC auth callback
if (uri.path == '/auth/callback' &&
if (path == '/auth/callback' &&
uri.queryParameters.containsKey('challenge')) {
final challenge = uri.queryParameters['challenge']!;
eventBus.fire(OidcAuthCallbackEvent(challenge));
@@ -129,7 +131,6 @@ class _AppWrapperState extends ConsumerState<AppWrapper>
}
final router = ref.read(routerProvider);
String path = '/${uri.host}${uri.path}';
if (uri.queryParameters.isNotEmpty) {
path =
Uri.parse(