From 6a052d47ab681debfecdc86f060f30f0ef690fa2 Mon Sep 17 00:00:00 2001 From: Sandaru Lashan Herman <165351637+SandaruEARL@users.noreply.github.com> Date: Sat, 15 Mar 2025 11:34:29 +0530 Subject: [PATCH 1/2] Create pubspec.lock --- packages/zulip_plugin/pubspec.lock | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 packages/zulip_plugin/pubspec.lock diff --git a/packages/zulip_plugin/pubspec.lock b/packages/zulip_plugin/pubspec.lock new file mode 100644 index 0000000000..e4de75859b --- /dev/null +++ b/packages/zulip_plugin/pubspec.lock @@ -0,0 +1,6 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: {} +sdks: + dart: ">=3.4.0-256.0.dev <4.0.0" + flutter: ">=3.3.0" From 6a04d4bbb8bb0148d223370ba6ad426baf177c3e Mon Sep 17 00:00:00 2001 From: Sandaru Lashan Herman <165351637+SandaruEARL@users.noreply.github.com> Date: Sat, 15 Mar 2025 22:49:08 +0530 Subject: [PATCH 2/2] Fix Google Sign-In 'Open-With' pop-up issue --- lib/widgets/login.dart | 57 ++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/lib/widgets/login.dart b/lib/widgets/login.dart index 504289adc1..d9b6059d8a 100644 --- a/lib/widgets/login.dart +++ b/lib/widgets/login.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:flutter/foundation.dart'; +//import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -333,43 +333,40 @@ class _LoginPageState extends State { }); } } - + // Fixed misbehavior Future _beginWebAuth(ExternalAuthenticationMethod method) async { - __otp = generateOtp(); + __otp = generateOtp(); // Ensure OTP is generated + + if (_otp == null || _otp!.isEmpty) { + debugLog('Error: OTP generation failed'); + return; + } + try { - final url = widget.serverSettings.realmUrl.resolve(method.loginUrl) - .replace(queryParameters: {'mobile_flow_otp': _otp!}); + // Construct the authentication URL + final Uri authUrl = widget.serverSettings.realmUrl.resolve(method.loginUrl) + .replace(queryParameters: {'mobile_flow_otp': _otp!}); - // Could set [_inProgress]… but we'd need to unset it if the web-auth - // attempt is aborted (by the user closing the browser, for example), - // and I don't think we can reliably know when that happens. - await ZulipBinding.instance.launchUrl(url, mode: LaunchMode.inAppBrowserView); - } catch (e) { - assert(debugLog(e.toString())); + // Log the authentication URL + debugLog('Opening authentication URL: $authUrl'); - if (e is PlatformException - && defaultTargetPlatform == TargetPlatform.iOS - && e.message != null && e.message!.startsWith('Error while launching')) { - // Ignore; I've seen this on my iPhone even when auth succeeds. - // Specifically, Apple web auth…which on iOS should be replaced by - // Apple native auth; that's #462. - // Possibly related: - // https://github.com/flutter/flutter/issues/91660 - // but in that issue, people report authentication not succeeding. - // TODO(#462) remove this? - return; - } + // Always use external browser to prevent "Open With" popup + await ZulipBinding.instance.launchUrl( + authUrl, + mode: LaunchMode.externalApplication, + ); + } catch (e, stackTrace) { + debugLog('Error during web auth: $e\nStackTrace: $stackTrace'); if (!mounted) return; - final zulipLocalizations = ZulipLocalizations.of(context); - String message = zulipLocalizations.errorWebAuthOperationalError; - if (e is PlatformException && e.message != null) { - message = e.message!; - } - showErrorDialog(context: context, + // Show an error message to the user + final zulipLocalizations = ZulipLocalizations.of(context); + showErrorDialog( + context: context, title: zulipLocalizations.errorWebAuthOperationalErrorTitle, - message: message); + message: zulipLocalizations.errorWebAuthOperationalError, + ); } }