Skip to content

Commit

Permalink
Update FIRAuthRecaptchaVerifier.m
Browse files Browse the repository at this point in the history
  • Loading branch information
renkelvin committed Jul 25, 2023
1 parent 24d0944 commit d436fdc
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions FirebaseAuth/Sources/Utilities/FIRAuthRecaptchaVerifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ - (void)verifyForceRefresh:(BOOL)forceRefresh
}
});
} else {
NSLog(@"reCAPTCHA verification faled because reCAPTCHA SDK "
@"not linked.");
completion(nil,
[FIRAuthErrorUtils recaptchaSDKNotLinkedError]);
}
} else {
NSLog(@"reCAPTCHA verification faled because reCAPTCHA SDK "
@"not linked.");
completion(nil,
[FIRAuthErrorUtils recaptchaSDKNotLinkedError]);
}
Expand Down Expand Up @@ -156,10 +160,12 @@ - (void)retrieveRecaptchaConfigForceRefresh:(BOOL)forceRefresh
callback:^(FIRGetRecaptchaConfigResponse *_Nullable response,
NSError *_Nullable error) {
if (error) {
NSLog(@"reCAPTCHA config retrieval failed.");
completion(error);
}
NSLog(@"reCAPTCHA config retrieval succeeded.");
FIRAuthRecaptchaConfig *config = [[FIRAuthRecaptchaConfig alloc] init];
// Response's site key is of the format projects/<project-id>/keys/<site-key>'
config.siteKey = [response.recaptchaKey componentsSeparatedByString:@"/"][3];
NSMutableDictionary *tmpEnablementStatus = [NSMutableDictionary dictionary];
for (NSDictionary *state in response.enforcementState) {
Expand Down Expand Up @@ -208,16 +214,18 @@ - (void)retrieveRecaptchaTokenWithAction:(FIRAuthRecaptchaAction)action
[[RecaptchaActionClass alloc] init], customActionSelector, actionToStringMap[@(action)]);

if (customAction) {
[self.recaptchaClient execute:customAction
completion:^(NSString *_Nullable token, NSError *_Nullable error) {
if (!error) {
NSLog(@"reCAPTCHA token retrieval succeeded.");
completion(token, nil);
return;
} else {
completion(kFakeToken, nil);
}
}];
[self.recaptchaClient
execute:customAction
completion:^(NSString *_Nullable token, NSError *_Nullable error) {
if (!error) {
NSLog(@"reCAPTCHA token retrieval succeeded.");
completion(token, nil);
return;
} else {
NSLog(@"reCAPTCHA token retrieval failed. NO_RECAPTCHA sent as the fake code.");
completion(kFakeToken, nil);
}
}];
}
} else {
completion(nil, [FIRAuthErrorUtils recaptchaSDKNotLinkedError]);
Expand Down

0 comments on commit d436fdc

Please sign in to comment.