From 3e5669780f52ae27cee4d8f931bcd3bc628bb340 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 15 Jun 2025 23:38:24 +0800 Subject: [PATCH] :bug: Fixes bugs on OAuth --- android/app/build.gradle.kts | 19 ++++-- ios/Podfile.lock | 43 +++++++++++++ ios/Runner/Info.plist | 8 +++ lib/screens/auth/login.dart | 56 ++++++++++------- macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 60 +++++++++++++++++-- pubspec.yaml | 1 + 7 files changed, 157 insertions(+), 32 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index f409c8f..ee8d29b 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -18,9 +18,7 @@ android { targetCompatibility = JavaVersion.VERSION_17 } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - } + kotlinOptions { jvmTarget = JavaVersion.VERSION_17.toString() } defaultConfig { applicationId = "dev.solsynth.solian" @@ -32,11 +30,20 @@ android { versionName = flutter.versionName } + signingConfigs { + release { + keyAlias = keystoreProperties['keyAlias'] + keyPassword = keystoreProperties['keyPassword'] + storeFile = keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null + storePassword = keystoreProperties['storePassword'] + } + } + buildTypes { release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig = signingConfigs.getByName("debug") + signingConfig = signingConfigs.getByName("release") + minifyEnabled = true + shrinkResources = true } } } diff --git a/ios/Podfile.lock b/ios/Podfile.lock index acaa896..52c5629 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,5 +1,15 @@ PODS: - Alamofire (5.10.2) + - AppAuth (1.7.6): + - AppAuth/Core (= 1.7.6) + - AppAuth/ExternalUserAgent (= 1.7.6) + - AppAuth/Core (1.7.6) + - AppAuth/ExternalUserAgent (1.7.6): + - AppAuth/Core + - AppCheckCore (11.2.0): + - GoogleUtilities/Environment (~> 8.0) + - GoogleUtilities/UserDefaults (~> 8.0) + - PromisesObjC (~> 2.4) - connectivity_plus (0.0.1): - Flutter - croppy (0.0.1): @@ -95,9 +105,20 @@ PODS: - gal (1.0.0): - Flutter - FlutterMacOS + - google_sign_in_ios (0.0.1): + - AppAuth (>= 1.7.4) + - Flutter + - FlutterMacOS + - GoogleSignIn (~> 8.0) + - GTMSessionFetcher (>= 3.4.0) - GoogleDataTransport (10.1.0): - nanopb (~> 3.30910.0) - PromisesObjC (~> 2.4) + - GoogleSignIn (8.0.0): + - AppAuth (< 2.0, >= 1.7.3) + - AppCheckCore (~> 11.0) + - GTMAppAuth (< 5.0, >= 4.1.1) + - GTMSessionFetcher/Core (~> 3.3) - GoogleUtilities/AppDelegateSwizzler (8.1.0): - GoogleUtilities/Environment - GoogleUtilities/Logger @@ -122,6 +143,14 @@ PODS: - GoogleUtilities/UserDefaults (8.1.0): - GoogleUtilities/Logger - GoogleUtilities/Privacy + - GTMAppAuth (4.1.1): + - AppAuth/Core (~> 1.7) + - GTMSessionFetcher/Core (< 4.0, >= 3.3) + - GTMSessionFetcher (3.5.0): + - GTMSessionFetcher/Full (= 3.5.0) + - GTMSessionFetcher/Core (3.5.0) + - GTMSessionFetcher/Full (3.5.0): + - GTMSessionFetcher/Core - image_picker_ios (0.0.1): - Flutter - irondash_engine_context (0.0.1): @@ -212,6 +241,7 @@ DEPENDENCIES: - flutter_udid (from `.symlinks/plugins/flutter_udid/ios`) - flutter_webrtc (from `.symlinks/plugins/flutter_webrtc/ios`) - gal (from `.symlinks/plugins/gal/darwin`) + - google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - irondash_engine_context (from `.symlinks/plugins/irondash_engine_context/ios`) - Kingfisher (~> 8.0) @@ -234,6 +264,8 @@ DEPENDENCIES: SPEC REPOS: trunk: - Alamofire + - AppAuth + - AppCheckCore - DKImagePickerController - DKPhotoGallery - Firebase @@ -242,7 +274,10 @@ SPEC REPOS: - FirebaseInstallations - FirebaseMessaging - GoogleDataTransport + - GoogleSignIn - GoogleUtilities + - GTMAppAuth + - GTMSessionFetcher - Kingfisher - nanopb - OrderedSet @@ -282,6 +317,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_webrtc/ios" gal: :path: ".symlinks/plugins/gal/darwin" + google_sign_in_ios: + :path: ".symlinks/plugins/google_sign_in_ios/darwin" image_picker_ios: :path: ".symlinks/plugins/image_picker_ios/ios" irondash_engine_context: @@ -319,6 +356,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Alamofire: 7193b3b92c74a07f85569e1a6c4f4237291e7496 + AppAuth: d4f13a8fe0baf391b2108511793e4b479691fb73 + AppCheckCore: cc8fd0a3a230ddd401f326489c99990b013f0c4f connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd croppy: 979e8ddc254f4642bffe7d52dc7193354b27ba30 device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe @@ -340,8 +379,12 @@ SPEC CHECKSUMS: flutter_udid: f7c3884e6ec2951efe4f9de082257fc77c4d15e9 flutter_webrtc: fd0d3bdef8766a0736dbbe2e5b7e85f1f3c52117 gal: baecd024ebfd13c441269ca7404792a7152fde89 + google_sign_in_ios: b48bb9af78576358a168361173155596c845f0b9 GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7 + GoogleSignIn: ce8c89bb9b37fb624b92e7514cc67335d1e277e4 GoogleUtilities: 00c88b9a86066ef77f0da2fab05f65d7768ed8e1 + GTMAppAuth: f69bd07d68cd3b766125f7e072c45d7340dea0de + GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6 image_picker_ios: 7fe1ff8e34c1790d6fff70a32484959f563a928a irondash_engine_context: 8e58ca8e0212ee9d1c7dc6a42121849986c88486 Kingfisher: 0621d0ac0c78fecb19f6dc5303bde2b52abaf2f5 diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index ac3c1d7..858ede3 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -2,6 +2,14 @@ + CLIENT_ID + 961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig.apps.googleusercontent.com + REVERSED_CLIENT_ID + com.googleusercontent.apps.961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig + PLIST_VERSION + 1 + BUNDLE_ID + dev.solsynth.solian ITSAppUsesNonExemptEncryption CADisableMinimumFrameDurationOnPhone diff --git a/lib/screens/auth/login.dart b/lib/screens/auth/login.dart index a2f2caf..ca6c9ac 100644 --- a/lib/screens/auth/login.dart +++ b/lib/screens/auth/login.dart @@ -12,6 +12,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_otp_text_field/flutter_otp_text_field.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:google_sign_in/google_sign_in.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:gap/gap.dart'; import 'package:island/models/auth.dart'; @@ -578,6 +579,7 @@ class _LoginLookupScreen extends HookConsumerWidget { data: { 'identity_token': credential.identityToken!, 'authorization_code': credential.authorizationCode, + 'device_id': await getUdid(), }, ); final token = resp.data['token']; @@ -602,6 +604,25 @@ class _LoginLookupScreen extends HookConsumerWidget { } } + Future withGoogle() async { + // TODO This crashes for no reason + GoogleSignIn gsi = GoogleSignIn( + clientId: + kIsWeb + ? '961776991058-963m1qin2vtp8fv693b5fdrab5hmpl89.apps.googleusercontent.com' + : (Platform.isIOS || Platform.isMacOS) + ? '961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig.apps.googleusercontent.com' + : '961776991058-r4iv9qoio57ul7utbfpgfrda2etvtch8.apps.googleusercontent.com', + scopes: ['openid', 'https://www.googleapis.com/auth/userinfo.email'], + ); + + try { + var ga = await gsi.signIn(); + } catch (err) { + showErrorAlert(err); + } + } + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -637,26 +658,16 @@ class _LoginLookupScreen extends HookConsumerWidget { Text("loginOr").tr().fontSize(11).opacity(0.85), const Gap(8), Spacer(), - IconButton.filledTonal( - onPressed: () async {}, - padding: EdgeInsets.zero, - icon: SvgPicture.asset( - 'assets/images/oidc/google.svg', - width: 16, - height: 16, - ), - tooltip: 'Google', - ), - IconButton.filledTonal( - onPressed: () async {}, - padding: EdgeInsets.zero, - icon: SvgPicture.asset( - 'assets/images/oidc/microsoft.svg', - width: 16, - height: 16, - ), - tooltip: 'Microsoft', - ), + // IconButton.filledTonal( + // // onPressed: withGoogle, + // padding: EdgeInsets.zero, + // icon: SvgPicture.asset( + // 'assets/images/oidc/google.svg', + // width: 16, + // height: 16, + // ), + // tooltip: 'Google', + // ), IconButton.filledTonal( onPressed: withApple, padding: EdgeInsets.zero, @@ -664,6 +675,11 @@ class _LoginLookupScreen extends HookConsumerWidget { 'assets/images/oidc/apple.svg', width: 16, height: 16, + color: + MediaQuery.of(context).platformBrightness == + Brightness.light + ? Colors.black54 + : Colors.white, ), tooltip: 'Apple Account', ), diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 8824bf0..3dfea74 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -18,6 +18,7 @@ import flutter_timezone import flutter_udid import flutter_webrtc import gal +import google_sign_in_ios import irondash_engine_context import livekit_client import media_kit_libs_macos_video @@ -49,6 +50,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FlutterUdidPlugin.register(with: registry.registrar(forPlugin: "FlutterUdidPlugin")) FlutterWebRTCPlugin.register(with: registry.registrar(forPlugin: "FlutterWebRTCPlugin")) GalPlugin.register(with: registry.registrar(forPlugin: "GalPlugin")) + FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin")) IrondashEngineContextPlugin.register(with: registry.registrar(forPlugin: "IrondashEngineContextPlugin")) LiveKitPlugin.register(with: registry.registrar(forPlugin: "LiveKitPlugin")) MediaKitLibsMacosVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitLibsMacosVideoPlugin")) diff --git a/pubspec.lock b/pubspec.lock index ce9c89c..8476725 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -493,18 +493,18 @@ packages: dependency: "direct main" description: name: drift - sha256: b584ddeb2b74436735dd2cf746d2d021e19a9a6770f409212fd5cbc2814ada85 + sha256: e60c715f045dd33624fc533efb0075e057debec9f39e83843e518f488a0e21fb url: "https://pub.dev" source: hosted - version: "2.26.1" + version: "2.27.0" drift_dev: dependency: "direct dev" description: name: drift_dev - sha256: "54dc207c6e4662741f60e5752678df183957ab907754ffab0372a7082f6d2816" + sha256: "7ad88b8982e753eadcdbc0ea7c7d30500598af733601428b5c9d264baf5106d6" url: "https://pub.dev" source: hosted - version: "2.26.1" + version: "2.27.0" drift_flutter: dependency: "direct main" description: @@ -997,6 +997,54 @@ packages: url: "https://pub.dev" source: hosted version: "6.2.1" + google_identity_services_web: + dependency: transitive + description: + name: google_identity_services_web + sha256: "5d187c46dc59e02646e10fe82665fc3884a9b71bc1c90c2b8b749316d33ee454" + url: "https://pub.dev" + source: hosted + version: "0.3.3+1" + google_sign_in: + dependency: "direct main" + description: + name: google_sign_in + sha256: d0a2c3bcb06e607bb11e4daca48bd4b6120f0bbc4015ccebbe757d24ea60ed2a + url: "https://pub.dev" + source: hosted + version: "6.3.0" + google_sign_in_android: + dependency: transitive + description: + name: google_sign_in_android + sha256: d5e23c56a4b84b6427552f1cf3f98f716db3b1d1a647f16b96dbb5b93afa2805 + url: "https://pub.dev" + source: hosted + version: "6.2.1" + google_sign_in_ios: + dependency: transitive + description: + name: google_sign_in_ios + sha256: "102005f498ce18442e7158f6791033bbc15ad2dcc0afa4cf4752e2722a516c96" + url: "https://pub.dev" + source: hosted + version: "5.9.0" + google_sign_in_platform_interface: + dependency: transitive + description: + name: google_sign_in_platform_interface + sha256: "5f6f79cf139c197261adb6ac024577518ae48fdff8e53205c5373b5f6430a8aa" + url: "https://pub.dev" + source: hosted + version: "2.5.0" + google_sign_in_web: + dependency: transitive + description: + name: google_sign_in_web + sha256: "460547beb4962b7623ac0fb8122d6b8268c951cf0b646dd150d60498430e4ded" + url: "https://pub.dev" + source: hosted + version: "0.12.4+4" graphs: dependency: transitive description: @@ -2455,10 +2503,10 @@ packages: dependency: transitive description: name: win32 - sha256: "329edf97fdd893e0f1e3b9e88d6a0e627128cc17cc316a8d67fda8f1451178ba" + sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03" url: "https://pub.dev" source: hosted - version: "5.13.0" + version: "5.14.0" win32_registry: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index ccf7028..ed865a3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -115,6 +115,7 @@ dependencies: fl_chart: ^1.0.0 sign_in_with_apple: ^7.0.1 flutter_svg: ^2.1.0 + google_sign_in: ^6.3.0 dev_dependencies: flutter_test: