Skip to content

Commit 7ee7223

Browse files
committed
refactor: move common props to outside phone check for future totp implementation
1 parent 32ce836 commit 7ee7223

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

packages/auth/ios/RNFBAuth/RNFBAuthModule.m

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,22 +1730,24 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user {
17301730
NSMutableArray *enrolledFactors = [NSMutableArray array];
17311731

17321732
for (FIRMultiFactorInfo *hint in hints) {
1733-
// only support phone mutli factor
1734-
if ([hint isKindOfClass:[FIRPhoneMultiFactorInfo class]]) {
1735-
FIRPhoneMultiFactorInfo *phoneHint = (FIRPhoneMultiFactorInfo *)hint;
1736-
17371733
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,
1734+
[[[NSISO8601DateFormatter alloc] init] stringFromDate:hint.enrollmentDate];
1735+
1736+
NSMutableDictionary *factorDict = [@{
1737+
@"uid" : hint.UID,
1738+
@"factorId": hint.factorID,
1739+
@"displayName" : hint.displayName == nil ? [NSNull null] : hint.displayName,
17431740
@"enrollmentTime" : enrollmentTime,
17441741
// @deprecated enrollmentDate kept for backwards compatibility, please use enrollmentTime
17451742
@"enrollmentDate" : enrollmentTime,
1746-
@"phoneNumber" : phoneHint.phoneNumber,
1747-
}];
1748-
}
1743+
} mutableCopy];
1744+
1745+
// only support phone mutli factor
1746+
if ([hint isKindOfClass:[FIRPhoneMultiFactorInfo class]]) {
1747+
FIRPhoneMultiFactorInfo *phoneHint = (FIRPhoneMultiFactorInfo *)hint;
1748+
factorDict[@"phoneNumber"] = phoneHint.phoneNumber;
1749+
[enrolledFactors addObject:factorDict];
1750+
}
17491751
}
17501752
return enrolledFactors;
17511753
}

0 commit comments

Comments
 (0)