Skip to content

Commit 853d83c

Browse files
authored
[Auth] Fix unexpected nil in fetchSignInMethods success case (#13561)
1 parent 486a0a0 commit 853d83c

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

FirebaseAuth/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
# 11.2.0
1+
# Unreleased
22
- [Fixed] Fixed crashes that could occur in Swift continuation blocks running in the Xcode 16
33
betas. (#13480)
44
- [Fixed] Fixed Phone Auth via Sandbox APNS tokens that broke in 11.0.0. (#13479)
5+
- [Fixed] Fix crash when fetching sign in methods due to unexpected nil.
6+
Previously, fetching sign in methods could return both a `nil` array of sign
7+
in methods and a `nil` error. In such cases, an empty array is instead
8+
returned with the `nil` error. (#13550)
9+
510

611
# 11.1.0
712
- [fixed] Fixed `Swift.error` conformance for `AuthErrorCode`. (#13430)

FirebaseAuth/Sources/Swift/Auth/Auth.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ extension Auth: AuthInterop {
290290
completion: (([String]?, Error?) -> Void)? = nil) {
291291
kAuthGlobalWorkQueue.async {
292292
let request = CreateAuthURIRequest(identifier: email,
293-
continueURI: "http:www.google.com",
293+
continueURI: "http://www.google.com/",
294294
requestConfiguration: self.requestConfiguration)
295295
Task {
296296
do {

FirebaseAuth/Sources/Swift/Backend/RPC/CreateAuthURIResponse.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class CreateAuthURIResponse: AuthRPCResponse {
3333
/// A list of provider IDs the passed identifier could use to sign in with.
3434
var allProviders: [String]?
3535

36-
/// A list of sign-in methods available for the passed identifier.
37-
var signinMethods: [String]?
36+
/// A list of sign-in methods available for the passed identifier.
37+
var signinMethods: [String] = []
3838

3939
/// Bare initializer.
4040
required init() {}
@@ -45,6 +45,6 @@ class CreateAuthURIResponse: AuthRPCResponse {
4545
registered = dictionary["registered"] as? Bool ?? false
4646
forExistingProvider = dictionary["forExistingProvider"] as? Bool ?? false
4747
allProviders = dictionary["allProviders"] as? [String]
48-
signinMethods = dictionary["signinMethods"] as? [String]
48+
signinMethods = dictionary["signinMethods"] as? [String] ?? []
4949
}
5050
}

FirebaseAuth/Tests/SampleSwift/SwiftApiTests/EmailPasswordTests.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,15 @@ class EmailPasswordTests: TestsBase {
6969
waitForExpectations(timeout: TestsBase.kExpectationsTimeout)
7070
}
7171

72-
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
7372
func testSignInExistingUserWithEmailAndPasswordAsync() async throws {
7473
let auth = Auth.auth()
7574
try await auth.signIn(withEmail: kExistingEmailToSignIn, password: "password")
7675
XCTAssertEqual(auth.currentUser?.email,
7776
kExistingEmailToSignIn,
7877
"Signed user does not match request.")
78+
// Regression test for #13550. Auth enumeration protection is enabled for
79+
// the test project, so no sign in methods should be returned.
80+
let signInMethods = try await auth.fetchSignInMethods(forEmail: kExistingEmailToSignIn)
81+
XCTAssertEqual(signInMethods, [])
7982
}
8083
}

0 commit comments

Comments
 (0)