-
Notifications
You must be signed in to change notification settings - Fork 4k
[firebase_auth] implement missing auth functionality for web #1864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 = | ||
|
@@ -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 | ||
|
@@ -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, | ||
), | ||
Comment on lines
+233
to
+240
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was reading the documentation and... do we want to kick the user to the Android/iOS app from the web? This change kind of adds a requirement of setting up an iOSBundleID and an androidPackageName on a potentially web-only app. Can these attributes be passed to the ActionCodeSettings conditionally? Does this handle There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, we shouldn't force users to set up those attributes. I can change to make this optional but it would require modifying the plugin to not assert that these attributes are non-null and update the native code to gracefully handle non-null values too to keep the api behavior consistent on all platforms. Is that the route we want to go down or is there an alternative? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm deferring this one to @hterkelsen, he wrote the original implementation. IMO all these should be optional. I'm guessing in a web-only flow, those are never expected to be used, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since these are already required parameters in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this is out of the scope of this PR but there is currently no way for users to not include an Android Passing a null will cause the method to assert and passing an empty string will cause Firebase to throw an argument error. A possible hack might be to pass in a random string but that seems fragile and possibly dangerous. I think it would be a good idea to allow users to opt out of certain platforms by passing null. |
||
); | ||
return auth.sendSignInLinkToEmail(email, actionCodeSettings); | ||
} | ||
|
||
@override | ||
|
@@ -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); | ||
Comment on lines
+289
to
+290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might "Fail with an error if the email address is invalid or OTP in email link expires.". Docs. Does that case need to be handled, or would that exception (?) propagate to the client app? (I've seen other places in the web plugin with a similar pattern... How do the Android/iOS versions behave in that case?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now it looks like the function will throw a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yes, that 1698 is going to be handy. Thanks for pointing it out! |
||
return _fromJsUserCredential(userCredential); | ||
} | ||
|
||
@override | ||
|
Uh oh!
There was an error while loading. Please reload this page.