Skip to content

Commit 90b6d98

Browse files
authored
fix(auth, ios): filter out non-phone multifactor to avoid crash (#8645)
* refactor: filter out any multifactor besides phone * refactor: move common props to outside phone check for future totp implementation * style: run lint:ios:fix
1 parent bcd1f45 commit 90b6d98

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

packages/auth/ios/RNFBAuth/RNFBAuthModule.m

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,15 +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-
}
1473-
14741465
- (void)promiseRejectAuthException:(RCTPromiseRejectBlock)reject error:(NSError *)error {
14751466
NSDictionary *jsError = [self getJSError:error];
14761467

@@ -1737,19 +1728,25 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user {
17371728
- (NSArray<NSMutableDictionary *> *)convertMultiFactorData:(NSArray<FIRMultiFactorInfo *> *)hints {
17381729
NSMutableArray *enrolledFactors = [NSMutableArray array];
17391730

1740-
for (FIRPhoneMultiFactorInfo *hint in hints) {
1731+
for (FIRMultiFactorInfo *hint in hints) {
17411732
NSString *enrollmentTime =
17421733
[[[NSISO8601DateFormatter alloc] init] stringFromDate:hint.enrollmentDate];
1743-
[enrolledFactors addObject:@{
1734+
1735+
NSMutableDictionary *factorDict = [@{
17441736
@"uid" : hint.UID,
1745-
@"factorId" : [self getJSFactorId:(hint.factorID)],
1737+
@"factorId" : hint.factorID,
17461738
@"displayName" : hint.displayName == nil ? [NSNull null] : hint.displayName,
17471739
@"enrollmentTime" : enrollmentTime,
17481740
// @deprecated enrollmentDate kept for backwards compatibility, please use enrollmentTime
17491741
@"enrollmentDate" : enrollmentTime,
1750-
// phoneNumber only present on FIRPhoneMultiFactorInfo
1751-
@"phoneNumber" : hint.phoneNumber == nil ? [NSNull null] : hint.phoneNumber,
1752-
}];
1742+
} mutableCopy];
1743+
1744+
// only support phone mutli factor
1745+
if ([hint isKindOfClass:[FIRPhoneMultiFactorInfo class]]) {
1746+
FIRPhoneMultiFactorInfo *phoneHint = (FIRPhoneMultiFactorInfo *)hint;
1747+
factorDict[@"phoneNumber"] = phoneHint.phoneNumber;
1748+
[enrolledFactors addObject:factorDict];
1749+
}
17531750
}
17541751
return enrolledFactors;
17551752
}

0 commit comments

Comments
 (0)