Skip to content

Commit

Permalink
Error changes
Browse files Browse the repository at this point in the history
  • Loading branch information
renkelvin committed Nov 8, 2023
1 parent 09c2644 commit a346b93
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions FirebaseAuth/Sources/Backend/FIRAuthBackend.m
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@
*/
static NSString *const kInvalidRecaptchaVersion = @"INVALID_RECAPTCHA_VERSION";

/** @var kInvalidLoginCredentials
@brief This is the error message the server will respond with if the login credentails is
invalid. in the request.
*/
static NSString *const kInvalidLoginCredentials = @"INVALID_LOGIN_CREDENTIALS";

/** @var gBackendImplementation
@brief The singleton FIRAuthBackendImplementation instance to use.
*/
Expand Down Expand Up @@ -1641,6 +1647,11 @@ + (nullable NSError *)clientErrorWithServerErrorMessage:(NSString *)serverErrorM
message:serverErrorMessage];
}

if ([shortErrorMessage isEqualToString:kInvalidLoginCredentials]) {
return [FIRAuthErrorUtils errorWithCode:FIRAuthInternalErrorCodeInvalidLoginCredentials
message:serverErrorMessage];
}

// In this case we handle an error that might be specified in the underlying errors dictionary,
// the error message in determined based on the @c reason key in the dictionary.
if (errorDictionary[kErrorsKey]) {
Expand Down
4 changes: 4 additions & 0 deletions FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ typedef NS_ERROR_ENUM(FIRAuthErrorDomain, FIRAuthErrorCode){
*/
FIRAuthErrorCodeRecaptchaSDKNotLinked = 17208,

/** Indicates that the long in credentials is invalid.
*/
FIRAuthErrorCodeInvalidLoginCredentials = 17213,

/** Indicates an error occurred while attempting to access the keychain.
*/
FIRAuthErrorCodeKeychainError = 17995,
Expand Down
8 changes: 8 additions & 0 deletions FirebaseAuth/Sources/Utilities/FIRAuthErrorUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,10 @@
@"The reCAPTCHA SDK is not linked to your app. See "
@"https://cloud.google.com/recaptcha-enterprise/docs/instrument-ios-apps";

static NSString *const kFIRAuthErrorMessageInvalidLoginCredentials =
@"Login credentials invalid. It is possible that the email/password combination does not "
@"exist.";

/** @var FIRAuthErrorDescription
@brief The error descrioption, based on the error code.
@remarks No default case so that we get a compiler warning if a new value was added to the enum.
Expand Down Expand Up @@ -810,6 +814,8 @@
return kFIRAuthErrorMessageInvalidReqType;
case FIRAuthErrorCodeRecaptchaSDKNotLinked:
return kFIRAuthErrorMessageRecaptchaSDKNotLinked;
case FIRAuthErrorCodeInvalidLoginCredentials:
return kFIRAuthErrorMessageInvalidLoginCredentials;
}
}

Expand Down Expand Up @@ -997,6 +1003,8 @@
return @"ERROR_INVALID_REQ_TYPE";
case FIRAuthErrorCodeRecaptchaSDKNotLinked:
return @"ERROR_RECAPTCHA_SDK_NOT_LINKED";
case FIRAuthErrorCodeInvalidLoginCredentials:
return @"ERROR_INVALID_LOGIN_CREDENTIALS";
}
}

Expand Down
5 changes: 5 additions & 0 deletions FirebaseAuth/Sources/Utilities/FIRAuthInternalErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ typedef NS_ENUM(NSInteger, FIRAuthInternalErrorCode) {
FIRAuthInternalErrorCodeRecaptchaNotEnabled = FIRAuthPublicErrorCodeFlag |
FIRAuthErrorCodeRecaptchaNotEnabled,

/** Indicates that the login credentials is invalid.
*/
FIRAuthInternalErrorCodeInvalidLoginCredentials = FIRAuthPublicErrorCodeFlag |
FIRAuthErrorCodeInvalidLoginCredentials,

/** Indicates that the recaptcha sdk is not linked to the app.
*/
FIRAuthInternalErrorCodeRecaptchaSDKNotLinked = FIRAuthPublicErrorCodeFlag |
Expand Down

0 comments on commit a346b93

Please sign in to comment.