From e9911485409b6cb9c227962efa76d2923578c9a8 Mon Sep 17 00:00:00 2001 From: Nick Cooke Date: Tue, 10 Dec 2024 14:40:02 -0500 Subject: [PATCH] Review --- .../Utilities/AuthRecaptchaVerifier.swift | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/FirebaseAuth/Sources/Swift/Utilities/AuthRecaptchaVerifier.swift b/FirebaseAuth/Sources/Swift/Utilities/AuthRecaptchaVerifier.swift index c86d98db784..bb3373938e8 100644 --- a/FirebaseAuth/Sources/Swift/Utilities/AuthRecaptchaVerifier.swift +++ b/FirebaseAuth/Sources/Swift/Utilities/AuthRecaptchaVerifier.swift @@ -160,8 +160,12 @@ actionString: String, fakeToken: String) async -> (token: String, error: Error?, linked: Bool, actionCreated: Bool) { - if recaptchaClient != nil { - return await retrieveToken(actionString: actionString, fakeToken: fakeToken) + if let recaptchaClient { + return await retrieveToken( + actionString: actionString, + fakeToken: fakeToken, + recaptchaClient: recaptchaClient + ) } if let recaptcha = @@ -170,7 +174,11 @@ // let client = try await recaptcha.fetchClient(withSiteKey: siteKey) let client = try await recaptcha.getClient(withSiteKey: siteKey) recaptchaClient = client - return await retrieveToken(actionString: actionString, fakeToken: fakeToken) + return await retrieveToken( + actionString: actionString, + fakeToken: fakeToken, + recaptchaClient: client + ) } catch { return ("", error, true, true) } @@ -181,12 +189,15 @@ } private func retrieveToken(actionString: String, - fakeToken: String) async -> (token: String, error: Error?, - linked: Bool, actionCreated: Bool) { + fakeToken: String, + recaptchaClient: RCARecaptchaClientProtocol) async -> (token: String, + error: Error?, + linked: Bool, + actionCreated: Bool) { if let recaptchaAction = NSClassFromString("RecaptchaEnterprise.RCAAction") as? RCAActionProtocol.Type { let action = recaptchaAction.init(customAction: actionString) - let token = try? await recaptchaClient!.execute(withAction: action) + let token = try? await recaptchaClient.execute(withAction: action) return (token ?? "NO_RECAPTCHA", nil, true, true) } else { // RecaptchaEnterprise not linked.