Skip to content

Commit

Permalink
Improved error handling for Android and iOS.
Browse files Browse the repository at this point in the history
Updated FireAuth docs.
Updated deprecated API "fetchProvidersForEmail" to "fetchSignInMethodsForEmail".
Added "unlinkCredential".
Formatting fixes.
Updated changelog and brought wrapper inline with (flutter#915).
  • Loading branch information
slightfoot committed Nov 21, 2018
1 parent 9a17c4f commit b6801bb
Show file tree
Hide file tree
Showing 7 changed files with 915 additions and 277 deletions.
10 changes: 10 additions & 0 deletions packages/firebase_auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.6.7

* `FirebaseAuth` and `FirebaseUser` are now fully documented.
* `PlatformExceptions` now report error codes as stated in docs.
* Credentials can now be unlinked from Accounts with new methods on `FirebaseUser`.

## 0.6.6

* Users can now reauthenticate in response to operations that require a recent sign-in.

## 0.6.5

* Fixing async method `verifyPhoneNumber`, that would never return even in a successful call.
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_auth/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ android {
disable 'InvalidPackage'
}
dependencies {
api 'com.google.firebase:firebase-auth:16.0.4'
api 'com.google.firebase:firebase-auth:16.0.5'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

Large diffs are not rendered by default.

134 changes: 59 additions & 75 deletions packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m

Large diffs are not rendered by default.

554 changes: 492 additions & 62 deletions packages/firebase_auth/lib/firebase_auth.dart

Large diffs are not rendered by default.

178 changes: 174 additions & 4 deletions packages/firebase_auth/test/firebase_auth_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void main() {
case "updateProfile":
return null;
break;
case "fetchProvidersForEmail":
case "fetchSignInMethodsForEmail":
return List<String>(0);
break;
case "verifyPhoneNumber":
Expand Down Expand Up @@ -135,16 +135,16 @@ void main() {
);
});

test('fetchProvidersForEmail', () async {
test('fetchSignInMethodsForEmail', () async {
final List<String> providers =
await auth.fetchProvidersForEmail(email: kMockEmail);
await auth.fetchSignInMethodsForEmail(email: kMockEmail);
expect(providers, isNotNull);
expect(providers.length, 0);
expect(
log,
<Matcher>[
isMethodCall(
'fetchProvidersForEmail',
'fetchSignInMethodsForEmail',
arguments: <String, String>{
'email': kMockEmail,
'app': auth.app.name
Expand All @@ -154,6 +154,86 @@ void main() {
);
});

test('linkWithTwitterCredential', () async {
final FirebaseUser user = await auth.linkWithTwitterCredential(
authToken: kMockIdToken,
authTokenSecret: kMockAccessToken,
);
verifyUser(user);
expect(
log,
<Matcher>[
isMethodCall(
'linkWithTwitterCredential',
arguments: <String, String>{
'authToken': kMockIdToken,
'authTokenSecret': kMockAccessToken,
'app': auth.app.name,
},
),
],
);
});

test('signInWithTwitter', () async {
final FirebaseUser user = await auth.signInWithTwitter(
authToken: kMockIdToken,
authTokenSecret: kMockAccessToken,
);
verifyUser(user);
expect(
log,
<Matcher>[
isMethodCall(
'signInWithTwitter',
arguments: <String, String>{
'authToken': kMockIdToken,
'authTokenSecret': kMockAccessToken,
'app': auth.app.name,
},
),
],
);
});

test('linkWithGithubCredential', () async {
final FirebaseUser user = await auth.linkWithGithubCredential(
token: kMockGithubToken,
);
verifyUser(user);
expect(
log,
<Matcher>[
isMethodCall(
'linkWithGithubCredential',
arguments: <String, String>{
'token': kMockGithubToken,
'app': auth.app.name,
},
),
],
);
});

test('signInWithGithub', () async {
final FirebaseUser user = await auth.signInWithGithub(
token: kMockGithubToken,
);
verifyUser(user);
expect(
log,
<Matcher>[
isMethodCall(
'signInWithGithub',
arguments: <String, String>{
'token': kMockGithubToken,
'app': auth.app.name,
},
),
],
);
});

test('linkWithEmailAndPassword', () async {
final FirebaseUser user = await auth.linkWithEmailAndPassword(
email: kMockEmail,
Expand Down Expand Up @@ -637,6 +717,96 @@ void main() {
]);
});

test('unlinkEmailAndPassword', () async {
final FirebaseUser user = await auth.currentUser();
await user.unlinkEmailAndPassword();
expect(log, <Matcher>[
isMethodCall(
'currentUser',
arguments: <String, String>{'app': auth.app.name},
),
isMethodCall(
'unlinkCredential',
arguments: <String, String>{
'app': auth.app.name,
'provider': 'password',
},
),
]);
});

test('unlinkGoogleCredential', () async {
final FirebaseUser user = await auth.currentUser();
await user.unlinkGoogleCredential();
expect(log, <Matcher>[
isMethodCall(
'currentUser',
arguments: <String, String>{'app': auth.app.name},
),
isMethodCall(
'unlinkCredential',
arguments: <String, String>{
'app': auth.app.name,
'provider': 'google.com',
},
),
]);
});

test('unlinkFacebookCredential', () async {
final FirebaseUser user = await auth.currentUser();
await user.unlinkFacebookCredential();
expect(log, <Matcher>[
isMethodCall(
'currentUser',
arguments: <String, String>{'app': auth.app.name},
),
isMethodCall(
'unlinkCredential',
arguments: <String, String>{
'app': auth.app.name,
'provider': 'facebook.com',
},
),
]);
});

test('unlinkTwitterCredential', () async {
final FirebaseUser user = await auth.currentUser();
await user.unlinkTwitterCredential();
expect(log, <Matcher>[
isMethodCall(
'currentUser',
arguments: <String, String>{'app': auth.app.name},
),
isMethodCall(
'unlinkCredential',
arguments: <String, String>{
'app': auth.app.name,
'provider': 'twitter.com',
},
),
]);
});

test('unlinkGithubCredential', () async {
final FirebaseUser user = await auth.currentUser();
await user.unlinkGithubCredential();
expect(log, <Matcher>[
isMethodCall(
'currentUser',
arguments: <String, String>{'app': auth.app.name},
),
isMethodCall(
'unlinkCredential',
arguments: <String, String>{
'app': auth.app.name,
'provider': 'github.com',
},
),
]);
});

test('signInWithCustomToken', () async {
final FirebaseUser user =
await auth.signInWithCustomToken(token: kMockCustomToken);
Expand Down

0 comments on commit b6801bb

Please sign in to comment.