Skip to content

Commit

Permalink
[Auth] Phone Auth – Fallback to reCATCHA flow when "invalid app crede…
Browse files Browse the repository at this point in the history
…ntial" error is thrown (#13519)
  • Loading branch information
ncooke3 authored Aug 23, 2024
1 parent d010f4a commit c570e44
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions FirebaseAuth/Sources/Swift/AuthProvider/PhoneAuthProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,12 @@ import Foundation
} catch {
let nserror = error as NSError
// reCAPTCHA Flow if it's an invalid app credential or a missing app token.
if (nserror.code == AuthErrorCode.internalError.rawValue &&
(nserror.userInfo[NSUnderlyingErrorKey] as? NSError)?.code ==
AuthErrorCode.invalidAppCredential.rawValue) ||
nserror.code == AuthErrorCode.missingAppToken.rawValue {
return try await CodeIdentity
.recaptcha(reCAPTCHAFlowWithUIDelegate(withUIDelegate: uiDelegate))
} else {
guard nserror.code == AuthErrorCode.invalidAppCredential.rawValue || nserror
.code == AuthErrorCode.missingAppToken.rawValue else {
throw error
}
return try await CodeIdentity
.recaptcha(reCAPTCHAFlowWithUIDelegate(withUIDelegate: uiDelegate))
}
}

Expand Down

0 comments on commit c570e44

Please sign in to comment.