diff options
author | 2017-09-10 10:05:08 -0700 | |
---|---|---|
committer | 2017-09-10 10:05:08 -0700 | |
commit | af23702b560c2c10b54f063817fcd6bca369795e (patch) | |
tree | 6d01c384e44dbe7d55994dbdc49898afcbef0f31 /Firebase/Auth/Source/FIRAuthErrorUtils.m | |
parent | e27a3072f6287f2cc05762e61f017bd6b506ab58 (diff) |
ReCAPTCHA verification error handling (#241)
* reCAPTCHA error handling
* Improvements
* Addresses comments
Diffstat (limited to 'Firebase/Auth/Source/FIRAuthErrorUtils.m')
-rw-r--r-- | Firebase/Auth/Source/FIRAuthErrorUtils.m | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Firebase/Auth/Source/FIRAuthErrorUtils.m b/Firebase/Auth/Source/FIRAuthErrorUtils.m index d5b1c9b..bfa0c41 100644 --- a/Firebase/Auth/Source/FIRAuthErrorUtils.m +++ b/Firebase/Auth/Source/FIRAuthErrorUtils.m @@ -42,6 +42,13 @@ NSString *const FIRAuthUpdatedCredentialKey = @"FIRAuthUpdatedCredentialKey"; */ static NSString *const kServerErrorDetailMarker = @" : "; +#pragma mark - URL response error codes + +/** @var kURLResponseErrorCodeInvalidClientID + @brief Error code that indicates that the client ID provided was invalid. + */ +static NSString *const kURLResponseErrorCodeInvalidClientID = @"auth/invalid-oauth-client-id"; + #pragma mark - Standard Error Messages /** @var kFIRAuthErrorMessageInvalidCustomToken @@ -357,6 +364,18 @@ static NSString *const kFIRAuthErrorMessageWebContextAlreadyPresented = @"User i static NSString *const kFIRAuthErrorMessageWebContextCancelled = @"The interaction was cancelled " "by the user."; +/** @var kFIRAuthErrorMessageInvalidClientID + @brief Message for @c FIRAuthErrorCodeInvalidClientID error code. + */ +static NSString *const kFIRAuthErrorMessageInvalidClientID = @"The OAuth client ID provided is " + "either invalid or does not match the specified API key."; + +/** @var kFIRAuthErrorMessageAppVerificationUserInteractionFailure + @brief Message for @c FIRAuthErrorCodeInvalidClientID error code. + */ +static NSString *const kFIRAuthErrorMessageAppVerificationUserInteractionFailure = @"The app " + "verification process has failed, print and inspect the error details for more information"; + /** @var kFIRAuthErrorMessageInternalError @brief Message for @c FIRAuthErrorCodeInternalError error code. */ @@ -471,6 +490,10 @@ static NSString *FIRAuthErrorDescription(FIRAuthErrorCode code) { return kFIRAuthErrorMessageWebContextAlreadyPresented; case FIRAuthErrorCodeWebContextCancelled: return kFIRAuthErrorMessageWebContextCancelled; + case FIRAuthErrorCodeInvalidClientID: + return kFIRAuthErrorMessageInvalidClientID; + case FIRAuthErrorCodeAppVerificationUserInteractionFailure: + return kFIRAuthErrorMessageAppVerificationUserInteractionFailure; } } @@ -582,6 +605,10 @@ static NSString *const FIRAuthErrorCodeString(FIRAuthErrorCode code) { return @"ERROR_WEB_CONTEXT_ALREADY_PRESENTED"; case FIRAuthErrorCodeWebContextCancelled: return @"ERROR_WEB_CONTEXT_CANCELLED"; + case FIRAuthErrorCodeInvalidClientID: + return @"ERROR_INVALID_CLIENT_ID"; + case FIRAuthErrorCodeAppVerificationUserInteractionFailure: + return @"ERROR_APP_VERIFICATION_FAILED"; } } @@ -902,6 +929,20 @@ static NSString *const FIRAuthErrorCodeString(FIRAuthErrorCode code) { return [self errorWithCode:FIRAuthInternalErrorCodeWebContextCancelled message:message]; } ++ (NSError *)appVerificationUserInteractionFailureWithReason:(nullable NSString *)reason { + return [self errorWithCode:FIRAuthInternalErrorCodeAppVerificationUserInteractionFailure + userInfo:@{ + NSLocalizedFailureReasonErrorKey : reason + }]; +} + ++ (NSError *)URLResponseErrorWithCode:(NSString *)code message:(nullable NSString *)message { + if ([code isEqualToString:kURLResponseErrorCodeInvalidClientID]) { + return [self errorWithCode:FIRAuthInternalErrorCodeInvalidClientID message:message]; + } + return nil; +} + + (NSError *)keychainErrorWithFunction:(NSString *)keychainFunction status:(OSStatus)status { NSString *failureReason = [NSString stringWithFormat:@"%@ (%li)", keychainFunction, (long)status]; return [self errorWithCode:FIRAuthInternalErrorCodeKeychainError userInfo:@{ |