Add send verification mail (#529)
diff --git a/packages/firebase_auth/CHANGELOG.md b/packages/firebase_auth/CHANGELOG.md index 9ee0799..3746073 100644 --- a/packages/firebase_auth/CHANGELOG.md +++ b/packages/firebase_auth/CHANGELOG.md
@@ -1,3 +1,7 @@ +## 0.5.7 + +* Added support to sendEmailVerification + ## 0.5.6 * Added support for linkWithFacebookCredential
diff --git a/packages/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java b/packages/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java index a42c591..489b5fb 100755 --- a/packages/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java +++ b/packages/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java
@@ -65,6 +65,9 @@ case "sendPasswordResetEmail": handleSendPasswordResetEmail(call, result); break; + case "sendEmailVerification": + handleSendEmailVerification(call, result); + break; case "signInWithEmailAndPassword": handleSignInWithEmailAndPassword(call, result); break; @@ -170,6 +173,13 @@ .addOnCompleteListener(new TaskVoidCompleteListener(result)); } + private void handleSendEmailVerification(MethodCall call, final Result result) { + firebaseAuth + .getCurrentUser() + .sendEmailVerification() + .addOnCompleteListener(new TaskVoidCompleteListener(result)); + } + private void handleSignInWithEmailAndPassword(MethodCall call, final Result result) { @SuppressWarnings("unchecked") Map<String, String> arguments = (Map<String, String>) call.arguments;
diff --git a/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m b/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m index 86df706..e2798e2 100644 --- a/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m +++ b/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m
@@ -99,6 +99,11 @@ completion:^(NSArray<NSString *> *providers, NSError *error) { [self sendResult:result forProviders:providers error:error]; }]; + } else if ([@"sendEmailVerification" isEqualToString:call.method]) { + [[FIRAuth auth].currentUser sendEmailVerificationWithCompletion:^(NSError *_Nullable error) { + [self sendResult:result forProviders:nil error:error]; + }]; + } else if ([@"sendPasswordResetEmail" isEqualToString:call.method]) { NSString *email = call.arguments[@"email"]; [[FIRAuth auth] sendPasswordResetWithEmail:email
diff --git a/packages/firebase_auth/lib/firebase_auth.dart b/packages/firebase_auth/lib/firebase_auth.dart index 1f814bb..a314728 100755 --- a/packages/firebase_auth/lib/firebase_auth.dart +++ b/packages/firebase_auth/lib/firebase_auth.dart
@@ -78,6 +78,10 @@ }); } + Future<void> sendEmailVerification() async { + await FirebaseAuth.channel.invokeMethod('sendEmailVerification'); + } + @override String toString() { return '$runtimeType($_data)';
diff --git a/packages/firebase_auth/pubspec.yaml b/packages/firebase_auth/pubspec.yaml index 27fca49..84a0c09 100755 --- a/packages/firebase_auth/pubspec.yaml +++ b/packages/firebase_auth/pubspec.yaml
@@ -4,7 +4,7 @@ and Twitter. author: Flutter Team <flutter-dev@googlegroups.com> homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_auth -version: 0.5.6 +version: 0.5.7 flutter: plugin:
diff --git a/packages/firebase_auth/test/firebase_auth_test.dart b/packages/firebase_auth/test/firebase_auth_test.dart index 07e9cdf..b849c9a 100755 --- a/packages/firebase_auth/test/firebase_auth_test.dart +++ b/packages/firebase_auth/test/firebase_auth_test.dart
@@ -228,6 +228,25 @@ ); }); + test('sendEmailVerification', () async { + final FirebaseUser user = await auth.currentUser(); + await user.sendEmailVerification(); + + expect( + log, + <Matcher>[ + isMethodCall( + 'currentUser', + arguments: null, + ), + isMethodCall( + 'sendEmailVerification', + arguments: null, + ), + ], + ); + }); + test('sendPasswordResetEmail', () async { await auth.sendPasswordResetEmail( email: kMockEmail,