Skip to content

Commit 091808d

Browse files
authored
Merge pull request #1 from schultek/master
Merge from schultek:master
2 parents bc7c1f3 + 6229f46 commit 091808d

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

lib/src/auth.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import 'auth/auth_api_request.dart';
88
import 'auth/user_record.dart';
99
import 'service.dart';
1010

11+
export 'auth/user_record.dart';
12+
1113
/// The Firebase Auth service interface.
1214
class Auth implements FirebaseService {
1315
@override
@@ -35,6 +37,15 @@ class Auth implements FirebaseService {
3537
return UserRecord.fromJson(response['users'][0]);
3638
}
3739

40+
/// Gets the user data for the users corresponding to the given [uids].
41+
Future<List<UserRecord>> getUsers(List<String> uids) async {
42+
var response = await _authRequestHandler.getAccountInfoByUids(uids);
43+
// Returns the user record populated with server response.
44+
return (response['users'] as List)
45+
.map((u) => UserRecord.fromJson(u))
46+
.toList();
47+
}
48+
3849
/// Looks up the user identified by the provided email and returns a future
3950
/// that is fulfilled with a user record for the given user if that user is
4051
/// found.

lib/src/auth/auth_api_request.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ class AuthRequestHandler {
8787
});
8888
}
8989

90+
/// Looks up users by their uids.
91+
Future<Map<String, dynamic>> getAccountInfoByUids(List<String> uids) async {
92+
if (uids.any((uid) => !validator.isUid(uid))) {
93+
throw FirebaseAuthError.invalidUid();
94+
}
95+
return _getAccountInfo({
96+
'localId': uids,
97+
});
98+
}
99+
90100
/// Looks up a user by email.
91101
Future<Map<String, dynamic>> getAccountInfoByEmail(String email) async {
92102
if (!validator.isEmail(email)) {
@@ -473,7 +483,10 @@ class CreateEditAccountRequest {
473483
// deleteProvider: ['phone'] with an array of providerIds (phone in this case),
474484
// will be passed.
475485
// Currently this applies to phone provider only.
476-
if (phoneNumber == '') 'deleteProvider': ['phone'],
486+
if (phoneNumber == '')
487+
'deleteProvider': ['phone'],
488+
if (customAttributes != null)
489+
'customAttributes': customAttributes,
477490
if (validSince != null)
478491
'validSince': validSince!.millisecondsSinceEpoch ~/ 1000
479492
};

lib/src/auth/user_record.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class UserMetadata {
1515
? null
1616
: DateTime.fromMillisecondsSinceEpoch(
1717
int.parse(map['createdAt'])),
18-
lastSignInTime: map['lastSignInTime'] == null
18+
lastSignInTime: map['lastLoginAt'] == null
1919
? null
2020
: DateTime.fromMillisecondsSinceEpoch(
21-
int.parse(map['lastSignInTime'])));
21+
int.parse(map['lastLoginAt'])));
2222

2323
Map<String, dynamic> toJson() {
2424
return {
25-
'lastSignInTime': lastSignInTime?.toIso8601String(),
25+
'lastLoginAt': lastSignInTime?.toIso8601String(),
2626
'creationTime': creationTime?.toIso8601String(),
2727
};
2828
}

0 commit comments

Comments
 (0)