Skip to content

Commit

Permalink
[firebase_auth] implement missing auth functionality for web (firebas…
Browse files Browse the repository at this point in the history
…e#1864)

* implement missing auth functionality for web

* add changelog

* bump pubspec version

* add missing method to changelog

* fix interface
  • Loading branch information
CDDelta authored Jan 29, 2020
1 parent a0b51b5 commit 8e7f774
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
4 changes: 4 additions & 0 deletions packages/firebase_auth/firebase_auth_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.2

* Implement `fetchSignInMethodsForEmail`, `isSignInWithEmailLink`, `signInWithEmailAndLink`, and `sendLinkToEmail`.

## 0.1.1+4

* Prevent `null` users (unauthenticated) from breaking the `onAuthStateChanged` Stream.
Expand Down
38 changes: 22 additions & 16 deletions packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform {

@override
Future<List<String>> fetchSignInMethodsForEmail(String app, String email) {
// TODO(hterkelsen): Use `fetchSignInMethodsForEmail` once
// https://github.com/FirebaseExtended/firebase-dart/issues/272
// is resolved.
throw UnimplementedError('fetchSignInMethodsForEmail');
final firebase.Auth auth = _getAuth(app);
return auth.fetchSignInMethodsForEmail(email);
}

@override
Expand All @@ -162,8 +160,6 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform {

@override
Future<PlatformIdTokenResult> getIdToken(String app, bool refresh) async {
// TODO(hterkelsen): `package:firebase` added `getIdTokenResult` in
// version 7.0.0. Use it here once that is published.
final firebase.Auth auth = _getAuth(app);
final firebase.User currentUser = auth.currentUser;
final firebase.IdTokenResult idTokenResult =
Expand All @@ -173,10 +169,8 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform {

@override
Future<bool> isSignInWithEmailLink(String app, String link) {
// TODO(hterkelsen): Implement this once
// https://github.com/FirebaseExtended/firebase-dart/issues/273
// is resolved.
throw UnimplementedError('isSignInWithEmailLink');
final firebase.Auth auth = _getAuth(app);
return Future.value(auth.isSignInWithEmailLink(link));
}

@override
Expand Down Expand Up @@ -232,9 +226,20 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform {
String androidPackageName,
bool androidInstallIfNotAvailable,
String androidMinimumVersion}) {
// TODO(hterkelsen): File issue with `package:firebase` to show
// `sendSignInLinkToEmail`.
throw UnimplementedError('sendLinkToEmail');
final firebase.Auth auth = _getAuth(app);
final actionCodeSettings = firebase.ActionCodeSettings(
url: url,
handleCodeInApp: handleCodeInApp,
iOS: firebase.IosSettings(
bundleId: iOSBundleID,
),
android: firebase.AndroidSettings(
packageName: androidPackageName,
installApp: androidInstallIfNotAvailable,
minimumVersion: androidMinimumVersion,
),
);
return auth.sendSignInLinkToEmail(email, actionCodeSettings);
}

@override
Expand Down Expand Up @@ -280,9 +285,10 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform {
@override
Future<PlatformAuthResult> signInWithEmailAndLink(
String app, String email, String link) async {
// TODO(hterkelsen): Use signInWithEmailLink once 7.0.0 of package:firebase
// is released.
throw UnimplementedError('signInWithEmailAndLink');
final firebase.Auth auth = _getAuth(app);
final firebase.UserCredential userCredential =
await auth.signInWithEmailLink(email, link);
return _fromJsUserCredential(userCredential);
}

@override
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_auth/firebase_auth_web/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: firebase_auth_web
description: The web implementation of firebase_auth
homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_auth/firebase_auth_web
version: 0.1.1+4
version: 0.1.2

flutter:
plugin:
Expand Down

0 comments on commit 8e7f774

Please sign in to comment.