Skip to content

Commit c570e44

Browse files
authored
[Auth] Phone Auth – Fallback to reCATCHA flow when "invalid app credential" error is thrown (#13519)
1 parent d010f4a commit c570e44

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

FirebaseAuth/Sources/Swift/AuthProvider/PhoneAuthProvider.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,12 @@ import Foundation
346346
} catch {
347347
let nserror = error as NSError
348348
// reCAPTCHA Flow if it's an invalid app credential or a missing app token.
349-
if (nserror.code == AuthErrorCode.internalError.rawValue &&
350-
(nserror.userInfo[NSUnderlyingErrorKey] as? NSError)?.code ==
351-
AuthErrorCode.invalidAppCredential.rawValue) ||
352-
nserror.code == AuthErrorCode.missingAppToken.rawValue {
353-
return try await CodeIdentity
354-
.recaptcha(reCAPTCHAFlowWithUIDelegate(withUIDelegate: uiDelegate))
355-
} else {
349+
guard nserror.code == AuthErrorCode.invalidAppCredential.rawValue || nserror
350+
.code == AuthErrorCode.missingAppToken.rawValue else {
356351
throw error
357352
}
353+
return try await CodeIdentity
354+
.recaptcha(reCAPTCHAFlowWithUIDelegate(withUIDelegate: uiDelegate))
358355
}
359356
}
360357

0 commit comments

Comments
 (0)