Skip to content

Commit 0e3e20d

Browse files
authored
[Auth] Restore MFA request setup to Firebase 10 behavior (#13858)
1 parent 2b75c5c commit 0e3e20d

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

FirebaseAuth/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Unreleased
2+
- [Fixed] Restore Firebase 10 behavior by ignoring `nil` display names used
3+
during multi factor enrollment. (#13856)
4+
15
# 11.3.0
26
- [Fixed] Restore Firebase 10 behavior by querying with the
37
`kSecAttrSynchronizable` key when auth state is set to be shared across

FirebaseAuth/Sources/Swift/Backend/RPC/MultiFactor/Enroll/FinalizeMFAEnrollmentRequest.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ class FinalizeMFAEnrollmentRequest: IdentityToolkitRequest, AuthRPCRequest {
6464
}
6565
if let displayName = displayName {
6666
body["displayName"] = displayName
67-
if let phoneVerificationInfo {
68-
body["phoneVerificationInfo"] = phoneVerificationInfo.dictionary
69-
} else if let totpVerificationInfo {
70-
body["totpVerificationInfo"] = totpVerificationInfo.dictionary
71-
}
67+
}
68+
if let phoneVerificationInfo {
69+
body["phoneVerificationInfo"] = phoneVerificationInfo.dictionary
70+
} else if let totpVerificationInfo {
71+
body["totpVerificationInfo"] = totpVerificationInfo.dictionary
7272
}
7373

7474
if let tenantID = tenantID {

FirebaseAuth/Tests/Unit/FinalizeMFAEnrollmentRequestTests.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ class FinalizeMFAEnrollmentRequestTests: RPCBaseTests {
2929
@brief Tests the Finalize MFA Enrollment using TOTP request.
3030
*/
3131
func testTOTPStartMFAEnrollmentRequest() async throws {
32+
try await assertTOTPStartMFAEnrollmentRequest(displayName: "sparky")
33+
}
34+
35+
func testTOTPStartMFAEnrollmentRequest_WhenDisplayNameIsNil() async throws {
36+
try await assertTOTPStartMFAEnrollmentRequest(displayName: nil)
37+
}
38+
39+
func assertTOTPStartMFAEnrollmentRequest(displayName: String?) async throws {
3240
let kIDToken = "idToken"
3341
let kDisplayName = "displayName"
3442
let kSessionInfo = "sessionInfo"
@@ -40,7 +48,7 @@ class FinalizeMFAEnrollmentRequestTests: RPCBaseTests {
4048
let requestInfo = AuthProtoFinalizeMFATOTPEnrollmentRequestInfo(sessionInfo: kSessionInfo,
4149
verificationCode: kVerificationCode)
4250
let request = FinalizeMFAEnrollmentRequest(idToken: kIDToken,
43-
displayName: kDisplayName,
51+
displayName: displayName,
4452
totpVerificationInfo: requestInfo,
4553
requestConfiguration: requestConfiguration)
4654

@@ -55,7 +63,7 @@ class FinalizeMFAEnrollmentRequestTests: RPCBaseTests {
5563
value: kIDToken
5664
)
5765
let requestDictionary = try XCTUnwrap(rpcIssuer.decodedRequest as? [String: AnyHashable])
58-
XCTAssertEqual(requestDictionary[kDisplayName], kDisplayName)
66+
XCTAssertEqual(requestDictionary[kDisplayName], displayName)
5967
let totpInfo = try XCTUnwrap(requestDictionary[kTOTPVerificationInfo] as? [String: String])
6068
XCTAssertEqual(totpInfo["verificationCode"], kVerificationCode)
6169
XCTAssertNil(requestDictionary[kPhoneVerificationInfo])

0 commit comments

Comments
 (0)