Skip to content

refactor: filter out any multifactor besides phone #8645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 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
38 changes: 18 additions & 20 deletions packages/auth/ios/RNFBAuth/RNFBAuthModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -1462,14 +1462,6 @@ - (NSDictionary *)multiFactorResolverToDict:(FIRMultiFactorResolver *)resolver {
}
#endif

- (NSString *)getJSFactorId:(NSString *)factorId {
if ([factorId isEqualToString:@"1"]) {
// Only phone is supported by the front-end so far
return @"phone";
}

return factorId;
}

- (void)promiseRejectAuthException:(RCTPromiseRejectBlock)reject error:(NSError *)error {
NSDictionary *jsError = [self getJSError:error];
Expand Down Expand Up @@ -1737,19 +1729,25 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user {
- (NSArray<NSMutableDictionary *> *)convertMultiFactorData:(NSArray<FIRMultiFactorInfo *> *)hints {
NSMutableArray *enrolledFactors = [NSMutableArray array];

for (FIRPhoneMultiFactorInfo *hint in hints) {
NSString *enrollmentTime =
for (FIRMultiFactorInfo *hint in hints) {
NSString *enrollmentTime =
[[[NSISO8601DateFormatter alloc] init] stringFromDate:hint.enrollmentDate];
[enrolledFactors addObject:@{
@"uid" : hint.UID,
@"factorId" : [self getJSFactorId:(hint.factorID)],
@"displayName" : hint.displayName == nil ? [NSNull null] : hint.displayName,
@"enrollmentTime" : enrollmentTime,
// @deprecated enrollmentDate kept for backwards compatibility, please use enrollmentTime
@"enrollmentDate" : enrollmentTime,
// phoneNumber only present on FIRPhoneMultiFactorInfo
@"phoneNumber" : hint.phoneNumber == nil ? [NSNull null] : hint.phoneNumber,
}];

NSMutableDictionary *factorDict = [@{
@"uid" : hint.UID,
@"factorId": hint.factorID,
@"displayName" : hint.displayName == nil ? [NSNull null] : hint.displayName,
@"enrollmentTime" : enrollmentTime,
// @deprecated enrollmentDate kept for backwards compatibility, please use enrollmentTime
@"enrollmentDate" : enrollmentTime,
} mutableCopy];

// only support phone mutli factor
if ([hint isKindOfClass:[FIRPhoneMultiFactorInfo class]]) {
FIRPhoneMultiFactorInfo *phoneHint = (FIRPhoneMultiFactorInfo *)hint;
factorDict[@"phoneNumber"] = phoneHint.phoneNumber;
[enrolledFactors addObject:factorDict];
}
}
return enrolledFactors;
}
Expand Down
Loading