diff --git a/packages/firebase_auth/CHANGELOG.md b/packages/firebase_auth/CHANGELOG.md index 0d55deeffbd2..cd866ad7547a 100644 --- a/packages/firebase_auth/CHANGELOG.md +++ b/packages/firebase_auth/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.13.1 + +* Fixed a crash on iOS when sign-in fails. +* Additional integration testing. +* Updated documentation for `FirebaseUser.delete()` to include error codes. +* Updated Firebase project to match other Flutterfire apps. + ## 0.13.0 * **Breaking change**: Replace `FirebaseUserMetadata.creationTimestamp` and diff --git a/packages/firebase_auth/example/android/app/build.gradle b/packages/firebase_auth/example/android/app/build.gradle index d31dce7a99f4..295870863a51 100755 --- a/packages/firebase_auth/example/android/app/build.gradle +++ b/packages/firebase_auth/example/android/app/build.gradle @@ -32,7 +32,7 @@ android { } defaultConfig { - applicationId "io.flutter.plugins.firebaseauthexample" + applicationId "dev.flutter.plugins.firebaseauthexample" minSdkVersion 16 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() diff --git a/packages/firebase_auth/example/android/app/google-services.json b/packages/firebase_auth/example/android/app/google-services.json old mode 100755 new mode 100644 index eccaa4d9da46..238110fbb63e --- a/packages/firebase_auth/example/android/app/google-services.json +++ b/packages/firebase_auth/example/android/app/google-services.json @@ -1,52 +1,300 @@ { "project_info": { - "project_number": "466218294969", - "firebase_url": "https://flutter-plugins-auth.firebaseio.com", - "project_id": "flutter-plugins-auth", - "storage_bucket": "flutter-plugins-auth.appspot.com" + "project_number": "159623150305", + "firebase_url": "https://flutter-firebase-plugins.firebaseio.com", + "project_id": "flutter-firebase-plugins", + "storage_bucket": "flutter-firebase-plugins.appspot.com" }, "client": [ { "client_info": { - "mobilesdk_app_id": "1:466218294969:android:11e8f037a4a3ec3b", + "mobilesdk_app_id": "1:159623150305:android:2e167f427b396288", + "android_client_info": { + "package_name": "dev.flutter.plugins.firebaseauthexample" + } + }, + "oauth_client": [ + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "159623150305-h67j0o93bcctblfhde74r7fssmcobamr.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebaseAuthExample" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:159623150305:android:236f9daea101f77e", + "android_client_info": { + "package_name": "io.flutter.plugins.firebase.firestoreexample" + } + }, + "oauth_client": [ + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "159623150305-h67j0o93bcctblfhde74r7fssmcobamr.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebaseAuthExample" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:159623150305:android:11e8f037a4a3ec3b", "android_client_info": { "package_name": "io.flutter.plugins.firebaseauthexample" } }, "oauth_client": [ { - "client_id": "466218294969-ikp8nslafq77v10dkp83f1atvfkacide.apps.googleusercontent.com", + "client_id": "159623150305-6cf91dro1kro30hdlfp3rkod8mldc81c.apps.googleusercontent.com", "client_type": 1, "android_info": { "package_name": "io.flutter.plugins.firebaseauthexample", - "certificate_hash": "f8323ac5fe6e7adc1ddc5612e16b5d04d7f1358b" + "certificate_hash": "4ef1514a34a8edf0f5b3ff7108d3497fa3449f69" } }, { - "client_id": "466218294969-t7bmju7plgllvluqpgb1gklfuv56pfr8.apps.googleusercontent.com", + "client_id": "159623150305-pjkkv9ff9tgkmjs7kjalsqv2pp6ltj04.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "io.flutter.plugins.firebaseauthexample", + "certificate_hash": "9ee6a0388f780cf93a852248905d2d3d83d8e50d" + } + }, + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { - "current_key": "AIzaSyA4il7ZGUO9gi7ErxFspGcaxi0qr9Huifc" + "current_key": "AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg" } ], "services": { - "analytics_service": { - "status": 1 + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "159623150305-h67j0o93bcctblfhde74r7fssmcobamr.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebaseAuthExample" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:159623150305:android:c68d3ad04a4046db", + "android_client_info": { + "package_name": "io.flutter.plugins.firebasedatabaseexample" + } + }, + "oauth_client": [ + { + "client_id": "159623150305-j5cqghi5snpqptesd2mdjum7o35hiltb.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "io.flutter.plugins.firebasedatabaseexample", + "certificate_hash": "9ee6a0388f780cf93a852248905d2d3d83d8e50d" + } }, + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg" + } + ], + "services": { "appinvite_service": { - "status": 2, "other_platform_oauth_client": [ { - "client_id": "466218294969-t7bmju7plgllvluqpgb1gklfuv56pfr8.apps.googleusercontent.com", + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", "client_type": 3 + }, + { + "client_id": "159623150305-h67j0o93bcctblfhde74r7fssmcobamr.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebaseAuthExample" + } } ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:159623150305:android:620f0e4ca16cbddd", + "android_client_info": { + "package_name": "io.flutter.plugins.firebasemessagingexample" + } + }, + "oauth_client": [ + { + "client_id": "159623150305-qubsrfqbnrp4vurajv72eujgk164nin0.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "io.flutter.plugins.firebasemessagingexample", + "certificate_hash": "f8323ac5fe6e7adc1ddc5612e16b5d04d7f1358b" + } }, - "ads_service": { - "status": 2 + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "159623150305-h67j0o93bcctblfhde74r7fssmcobamr.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebaseAuthExample" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:159623150305:android:ef48439a0cc0263d", + "android_client_info": { + "package_name": "io.flutter.plugins.firebasestorageexample" + } + }, + "oauth_client": [ + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "159623150305-h67j0o93bcctblfhde74r7fssmcobamr.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebaseAuthExample" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:159623150305:android:5e9f1f89e134dc86", + "android_client_info": { + "package_name": "io.flutter.plugins.googlesigninexample" + } + }, + "oauth_client": [ + { + "client_id": "159623150305-3suu3qq4vs3ki7uaigbtrh2aal1p9ram.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "io.flutter.plugins.googlesigninexample", + "certificate_hash": "f8323ac5fe6e7adc1ddc5612e16b5d04d7f1358b" + } + }, + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "159623150305-h67j0o93bcctblfhde74r7fssmcobamr.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "io.flutter.plugins.firebaseAuthExample" + } + } + ] } } } diff --git a/packages/firebase_auth/example/ios/Runner/GoogleService-Info.plist b/packages/firebase_auth/example/ios/Runner/GoogleService-Info.plist index 991d668efeea..2f48146fd821 100644 --- a/packages/firebase_auth/example/ios/Runner/GoogleService-Info.plist +++ b/packages/firebase_auth/example/ios/Runner/GoogleService-Info.plist @@ -2,39 +2,37 @@ - AD_UNIT_ID_FOR_BANNER_TEST - ca-app-pub-3940256099942544/2934735716 - AD_UNIT_ID_FOR_INTERSTITIAL_TEST - ca-app-pub-3940256099942544/4411468910 CLIENT_ID - 466218294969-5mdmh6opkqd87a5m81nm83u4eqd3bvgk.apps.googleusercontent.com + 159623150305-h67j0o93bcctblfhde74r7fssmcobamr.apps.googleusercontent.com REVERSED_CLIENT_ID - com.googleusercontent.apps.466218294969-5mdmh6opkqd87a5m81nm83u4eqd3bvgk + com.googleusercontent.apps.159623150305-h67j0o93bcctblfhde74r7fssmcobamr + ANDROID_CLIENT_ID + 159623150305-j5cqghi5snpqptesd2mdjum7o35hiltb.apps.googleusercontent.com API_KEY - AIzaSyCb0BM8Q9o_gCubuHvsxdxHSgDZaQoZrv0 + AIzaSyDyzecVw1zXTpBKwfFHxpl7QyYBhimNhUk GCM_SENDER_ID - 466218294969 + 159623150305 PLIST_VERSION 1 BUNDLE_ID io.flutter.plugins.firebaseAuthExample PROJECT_ID - flutter-plugins-auth + flutter-firebase-plugins STORAGE_BUCKET - flutter-plugins-auth.appspot.com + flutter-firebase-plugins.appspot.com IS_ADS_ENABLED - + IS_ANALYTICS_ENABLED IS_APPINVITE_ENABLED - + IS_GCM_ENABLED IS_SIGNIN_ENABLED GOOGLE_APP_ID - 1:466218294969:ios:8d89e1b69d780386 + 1:159623150305:ios:8d89e1b69d780386 DATABASE_URL - https://flutter-plugins-auth.firebaseio.com + https://flutter-firebase-plugins.firebaseio.com \ No newline at end of file diff --git a/packages/firebase_auth/example/pubspec.yaml b/packages/firebase_auth/example/pubspec.yaml index a72835476bcb..9478c9b1f34f 100755 --- a/packages/firebase_auth/example/pubspec.yaml +++ b/packages/firebase_auth/example/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: google_sign_in: ^4.0.0 firebase_core: ^0.4.0+8 firebase_dynamic_links: ^0.3.0 + uuid: ^2.0.2 dev_dependencies: flutter_driver: diff --git a/packages/firebase_auth/example/test/firebase_auth.dart b/packages/firebase_auth/example/test/firebase_auth.dart index 6acf6e6d9b62..e06b387f6802 100644 --- a/packages/firebase_auth/example/test/firebase_auth.dart +++ b/packages/firebase_auth/example/test/firebase_auth.dart @@ -5,6 +5,8 @@ import 'dart:async'; import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/services.dart'; +import 'package:uuid/uuid.dart'; import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -46,6 +48,30 @@ void main() { user2.metadata.lastSignInTime, equals(user2.metadata.creationTime)); }); + test('email auth', () async { + final String testEmail = 'testuser${Uuid().v4()}@example.com'; + final String testPassword = 'testpassword'; + AuthResult result = await auth.createUserWithEmailAndPassword( + email: testEmail, + password: testPassword, + ); + final FirebaseUser user = result.user; + expect(user.uid, isNotNull); + expect(user.isAnonymous, isFalse); + auth.signOut(); + final Future failedResult = auth.signInWithEmailAndPassword( + email: testEmail, + password: 'incorrect password', + ); + expect(failedResult, throwsA(isInstanceOf())); + result = await auth.signInWithEmailAndPassword( + email: testEmail, + password: testPassword, + ); + expect(result.user.uid, equals(user.uid)); + await user.delete(); + }); + test('isSignInWithEmailLink', () async { final String emailLink1 = 'https://www.example.com/action?mode=signIn&' 'oobCode=oobCode&apiKey=API_KEY'; diff --git a/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m b/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m index d6e469393314..dccbd28ee8fa 100644 --- a/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m +++ b/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m @@ -373,7 +373,7 @@ - (void)sendResult:(FlutterResult)result FIRAdditionalUserInfo *additionalUserInfo = authResult.additionalUserInfo; [self sendResult:result forObject:@{ - @"user" : (user != nil ? [self dictionaryFromUser:user] : nil), + @"user" : (user != nil ? [self dictionaryFromUser:user] : [NSNull null]), @"additionalUserInfo" : additionalUserInfo ? @{ @"isNewUser" : [NSNumber numberWithBool:additionalUserInfo.isNewUser], @"username" : additionalUserInfo.username ?: [NSNull null], diff --git a/packages/firebase_auth/lib/src/firebase_user.dart b/packages/firebase_auth/lib/src/firebase_user.dart index e9093ce2f1ad..c30a5aaf0c65 100644 --- a/packages/firebase_auth/lib/src/firebase_user.dart +++ b/packages/firebase_auth/lib/src/firebase_user.dart @@ -86,7 +86,13 @@ class FirebaseUser extends UserInfo { .invokeMethod('reload', {'app': _app.name}); } - /// Deletes the user record from your Firebase project's database. + /// Deletes the current user (also signs out the user). + /// + /// Errors: + /// • `ERROR_REQUIRES_RECENT_LOGIN` - If the user's last sign-in time does not meet the security threshold. Use reauthenticate methods to resolve. + /// • `ERROR_INVALID_CREDENTIAL` - If the credential is malformed or has expired. + /// • `ERROR_USER_DISABLED` - If the user has been disabled (for example, in the Firebase console) + /// • `ERROR_USER_NOT_FOUND` - If the user has been deleted (for example, in the Firebase console) Future delete() async { await FirebaseAuth.channel .invokeMethod('delete', {'app': _app.name}); diff --git a/packages/firebase_auth/pubspec.yaml b/packages/firebase_auth/pubspec.yaml index deabd4712be2..dd83322c0150 100755 --- a/packages/firebase_auth/pubspec.yaml +++ b/packages/firebase_auth/pubspec.yaml @@ -4,7 +4,7 @@ description: Flutter plugin for Firebase Auth, enabling Android and iOS like Google, Facebook and Twitter. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_auth -version: 0.13.0 +version: 0.13.1 flutter: plugin: @@ -22,6 +22,7 @@ dependencies: dev_dependencies: google_sign_in: ^3.0.4 firebase_dynamic_links: ^0.3.0 + uuid: ^2.0.2 test: ^1.3.0 flutter_test: sdk: flutter