Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/firebase_auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.0

* **Breaking Change**: Method FirebaseUser getToken was renamed to getIdToken.

## 0.2.5

* Added support for linkWithCredential with Google credential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void onMethodCall(MethodCall call, Result result) {
case "signOut":
handleSignOut(call, result);
break;
case "getToken":
case "getIdToken":
handleGetToken(call, result);
break;
case "linkWithEmailAndPassword":
Expand Down Expand Up @@ -210,7 +210,7 @@ private void handleGetToken(MethodCall call, final Result result) {
boolean refresh = arguments.get("refresh");
firebaseAuth
.getCurrentUser()
.getToken(refresh)
.getIdToken(refresh)
.addOnCompleteListener(
new OnCompleteListener<GetTokenResult>() {
public void onComplete(@NonNull Task<GetTokenResult> task) {
Expand Down
4 changes: 2 additions & 2 deletions packages/firebase_auth/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class _MyHomePageState extends State<MyHomePage> {
assert(user != null);
assert(user.isAnonymous);
assert(!user.isEmailVerified);
assert(await user.getToken() != null);
assert(await user.getIdToken() != null);
if (Platform.isIOS) {
// Anonymous auth doesn't show up as a provider on iOS
assert(user.providerData.isEmpty);
Expand Down Expand Up @@ -74,7 +74,7 @@ class _MyHomePageState extends State<MyHomePage> {
assert(user.email != null);
assert(user.displayName != null);
assert(!user.isAnonymous);
assert(await user.getToken() != null);
assert(await user.getIdToken() != null);

final FirebaseUser currentUser = await _auth.currentUser();
assert(user.uid == currentUser.uid);
Expand Down
12 changes: 6 additions & 6 deletions packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
} else {
[self sendResult:result forUser:nil error:nil];
}
} else if ([@"getToken" isEqualToString:call.method]) {
} else if ([@"getIdToken" isEqualToString:call.method]) {
[[FIRAuth auth].currentUser
getTokenForcingRefresh:YES
completion:^(NSString *_Nullable token, NSError *_Nullable error) {
result(error != nil ? error.flutterError : token);
}];
getIDTokenForcingRefresh:YES
completion:^(NSString *_Nullable token, NSError *_Nullable error) {
result(error != nil ? error.flutterError : token);
}];
} else if ([@"linkWithEmailAndPassword" isEqualToString:call.method]) {
NSString *email = call.arguments[@"email"];
NSString *password = call.arguments[@"password"];
FIRAuthCredential *credential =
[FIREmailPasswordAuthProvider credentialWithEmail:email password:password];
[FIREmailAuthProvider credentialWithEmail:email password:password];
[[FIRAuth auth].currentUser linkWithCredential:credential
completion:^(FIRUser *user, NSError *error) {
[self sendResult:result forUser:user error:error];
Expand Down
4 changes: 2 additions & 2 deletions packages/firebase_auth/lib/firebase_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class FirebaseUser extends UserInfo {
/// Obtains the id token for the current user, forcing a [refresh] if desired.
///
/// Completes with an error if the user is signed out.
Future<String> getToken({bool refresh: false}) {
return FirebaseAuth.channel.invokeMethod('getToken', <String, bool>{
Future<String> getIdToken({bool refresh: false}) {
return FirebaseAuth.channel.invokeMethod('getIdToken', <String, bool>{
'refresh': refresh,
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: firebase_auth
description: Firebase Auth plugin for Flutter.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_auth
version: 0.2.5
version: 0.3.0

flutter:
plugin:
Expand Down
11 changes: 6 additions & 5 deletions packages/firebase_auth/test/firebase_auth_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void main() {
FirebaseAuth.channel.setMockMethodCallHandler((MethodCall call) async {
log.add(call);
switch (call.method) {
case "getToken":
case "getIdToken":
return kMockIdToken;
break;
case "startListeningAuthState":
Expand Down Expand Up @@ -71,14 +71,15 @@ void main() {
test('signInAnonymously', () async {
final FirebaseUser user = await auth.signInAnonymously();
verifyUser(user);
expect(await user.getToken(), equals(kMockIdToken));
expect(await user.getToken(refresh: true), equals(kMockIdToken));
expect(await user.getIdToken(), equals(kMockIdToken));
expect(await user.getIdToken(refresh: true), equals(kMockIdToken));
expect(
log,
equals(<MethodCall>[
const MethodCall('signInAnonymously'),
const MethodCall('getToken', const <String, bool>{'refresh': false}),
const MethodCall('getToken', const <String, bool>{'refresh': true}),
const MethodCall(
'getIdToken', const <String, bool>{'refresh': false}),
const MethodCall('getIdToken', const <String, bool>{'refresh': true}),
]),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ public void onMethodCall(MethodCall call, final Result result) {
case "DatabaseReference#update":
{
Map<String, Object> arguments = call.arguments();
Map value = (Map) arguments.get("value");
@SuppressWarnings("unchecked")
Map<String, Object> value = (Map<String, Object>) arguments.get("value");
DatabaseReference reference = getReference(arguments);
reference.updateChildren(value, new DefaultCompletionListener(result));
break;
Expand Down