diff --git a/ios/RNFirebase/RNFirebaseAuth.m b/ios/RNFirebase/RNFirebaseAuth.m index 9173086f..a68ba8e1 100644 --- a/ios/RNFirebase/RNFirebaseAuth.m +++ b/ios/RNFirebase/RNFirebaseAuth.m @@ -636,6 +636,31 @@ RCT_EXPORT_METHOD(reauthenticate:(NSString *)provider authToken:(NSString *)auth } +/** + Converts an array of FIRUserInfo instances into the correct format to match the web sdk + + @param providerData FIRUser.providerData + @return NSArray + */ +- (NSArray *) convertProviderData:(NSArray > *) providerData { + NSEnumerator *items = [providerData objectEnumerator]; + NSMutableArray *output = [NSMutableArray array]; + + id userInfo; + while (userInfo = [items nextObject]) { + [output addObject:@{ + @"providerId": userInfo.providerID, + @"uid": userInfo.uid, + @"displayName": userInfo.displayName, + @"photoURL": userInfo.photoURL, + @"email": userInfo.email + } + ]; + } + + return output; +} + /** Converts a FIRUser instance into a dictionary to send via RNBridge @@ -650,7 +675,8 @@ RCT_EXPORT_METHOD(reauthenticate:(NSString *)provider authToken:(NSString *)auth @"isAnonymous": @(user.anonymous), @"displayName": user.displayName ? user.displayName : [NSNull null], @"refreshToken": user.refreshToken, - @"providerId": [user.providerID lowercaseString] + @"providerId": [user.providerID lowercaseString], + @"providerDate": [self convertProviderData: user.providerData] } mutableCopy ]; diff --git a/lib/modules/auth/user.js b/lib/modules/auth/user.js index 3ef519e1..89afc0d7 100644 --- a/lib/modules/auth/user.js +++ b/lib/modules/auth/user.js @@ -142,10 +142,13 @@ export default class User { return FirebaseAuth.getToken(forceRefresh); } - // TODO return from native - // get providerData() { - // return this._valueOrNull('providerData'); - // } + /** + * + * @returns {Array} + */ + get providerData(): Array { + return this._valueOrNull('providerData') || []; + } /** * Update the current user's email