Skip to content

Commit 2242869

Browse files
committed
refactor: filter out any multifactor besides phone
1 parent 14c3541 commit 2242869

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

packages/auth/ios/RNFBAuth/RNFBAuthModule.m

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,14 +1462,6 @@ - (NSDictionary *)multiFactorResolverToDict:(FIRMultiFactorResolver *)resolver {
14621462
}
14631463
#endif
14641464

1465-
- (NSString *)getJSFactorId:(NSString *)factorId {
1466-
if ([factorId isEqualToString:@"1"]) {
1467-
// Only phone is supported by the front-end so far
1468-
return @"phone";
1469-
}
1470-
1471-
return factorId;
1472-
}
14731465

14741466
- (void)promiseRejectAuthException:(RCTPromiseRejectBlock)reject error:(NSError *)error {
14751467
NSDictionary *jsError = [self getJSError:error];
@@ -1737,19 +1729,23 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user {
17371729
- (NSArray<NSMutableDictionary *> *)convertMultiFactorData:(NSArray<FIRMultiFactorInfo *> *)hints {
17381730
NSMutableArray *enrolledFactors = [NSMutableArray array];
17391731

1740-
for (FIRPhoneMultiFactorInfo *hint in hints) {
1741-
NSString *enrollmentTime =
1742-
[[[NSISO8601DateFormatter alloc] init] stringFromDate:hint.enrollmentDate];
1743-
[enrolledFactors addObject:@{
1744-
@"uid" : hint.UID,
1745-
@"factorId" : [self getJSFactorId:(hint.factorID)],
1746-
@"displayName" : hint.displayName == nil ? [NSNull null] : hint.displayName,
1747-
@"enrollmentTime" : enrollmentTime,
1748-
// @deprecated enrollmentDate kept for backwards compatibility, please use enrollmentTime
1749-
@"enrollmentDate" : enrollmentTime,
1750-
// phoneNumber only present on FIRPhoneMultiFactorInfo
1751-
@"phoneNumber" : hint.phoneNumber == nil ? [NSNull null] : hint.phoneNumber,
1752-
}];
1732+
for (FIRMultiFactorInfo *hint in hints) {
1733+
// only support phone mutli factor
1734+
if ([hint isKindOfClass:[FIRPhoneMultiFactorInfo class]]) {
1735+
FIRPhoneMultiFactorInfo *phoneHint = (FIRPhoneMultiFactorInfo *)hint;
1736+
1737+
NSString *enrollmentTime =
1738+
[[[NSISO8601DateFormatter alloc] init] stringFromDate:phoneHint.enrollmentDate];
1739+
[enrolledFactors addObject:@{
1740+
@"uid" : phoneHint.UID,
1741+
@"factorId" : FIRPhoneMultiFactorInfo.FIRPhoneMultiFactorID,
1742+
@"displayName" : phoneHint.displayName == nil ? [NSNull null] : phoneHint.displayName,
1743+
@"enrollmentTime" : enrollmentTime,
1744+
// @deprecated enrollmentDate kept for backwards compatibility, please use enrollmentTime
1745+
@"enrollmentDate" : enrollmentTime,
1746+
@"phoneNumber" : phoneHint.phoneNumber,
1747+
}];
1748+
}
17531749
}
17541750
return enrolledFactors;
17551751
}

0 commit comments

Comments
 (0)