diff options
author | 2017-08-11 17:12:11 -0700 | |
---|---|---|
committer | 2017-08-11 17:12:11 -0700 | |
commit | 8c3ef6b780d5b9b116c693b3b440dcc7f68b4827 (patch) | |
tree | 1c53f866e945324acd7fff5b93e77abb6333d994 /Firebase | |
parent | 6b0739790c637baf2e05b4bc339abb27cfb4f8cb (diff) |
Handles MISSING_EMAIL error from server. (#187)
Diffstat (limited to 'Firebase')
-rw-r--r-- | Firebase/Auth/Source/FIRAuth.m | 2 | ||||
-rw-r--r-- | Firebase/Auth/Source/FIRAuthErrorUtils.h | 5 | ||||
-rw-r--r-- | Firebase/Auth/Source/FIRAuthErrorUtils.m | 6 | ||||
-rw-r--r-- | Firebase/Auth/Source/RPCs/FIRAuthBackend.m | 10 |
4 files changed, 17 insertions, 6 deletions
diff --git a/Firebase/Auth/Source/FIRAuth.m b/Firebase/Auth/Source/FIRAuth.m index d5e6b0f..33af19e 100644 --- a/Firebase/Auth/Source/FIRAuth.m +++ b/Firebase/Auth/Source/FIRAuth.m @@ -723,7 +723,7 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; return; } if (![request.email length]) { - decoratedCallback(nil, [FIRAuthErrorUtils missingEmail]); + decoratedCallback(nil, [FIRAuthErrorUtils missingEmailErrorWithMessage:nil]); return; } [FIRAuthBackend signUpNewUser:request diff --git a/Firebase/Auth/Source/FIRAuthErrorUtils.h b/Firebase/Auth/Source/FIRAuthErrorUtils.h index 1dde98f..a857d4b 100644 --- a/Firebase/Auth/Source/FIRAuthErrorUtils.h +++ b/Firebase/Auth/Source/FIRAuthErrorUtils.h @@ -348,11 +348,12 @@ NS_ASSUME_NONNULL_BEGIN */ + (NSError *)missingContinueURIErrorWithMessage:(nullable NSString *)message; -/** @fn missingEmail +/** @fn missingEmailErrorWithMessage @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingEmail code. + @param message Error message from the backend, if any. @return The NSError instance associated with the given FIRAuthError. */ -+ (NSError *)missingEmail; ++ (NSError *)missingEmailErrorWithMessage:(nullable NSString *)message; /** @fn missingPhoneNumberErrorWithMessage: @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingPhoneNumber code. diff --git a/Firebase/Auth/Source/FIRAuthErrorUtils.m b/Firebase/Auth/Source/FIRAuthErrorUtils.m index 5c5b10a..42fb543 100644 --- a/Firebase/Auth/Source/FIRAuthErrorUtils.m +++ b/Firebase/Auth/Source/FIRAuthErrorUtils.m @@ -525,7 +525,7 @@ static NSString *const FIRAuthErrorCodeString(FIRAuthErrorCode code) { case FIRAuthErrorCodeMissingContinueURI: return @"ERROR_MISSING_CONTINUE_URI"; case FIRAuthErrorCodeMissingEmail: - return @"MISSING_EMAIL"; + return @"ERROR_MISSING_EMAIL"; case FIRAuthErrorCodeMissingPhoneNumber: return @"ERROR_MISSING_PHONE_NUMBER"; case FIRAuthErrorCodeInvalidPhoneNumber: @@ -803,8 +803,8 @@ static NSString *const FIRAuthErrorCodeString(FIRAuthErrorCode code) { return[self errorWithCode:FIRAuthInternalErrorCodeMissingContinueURI message:message]; } -+ (NSError *)missingEmail { - return [self errorWithCode:FIRAuthInternalErrorCodeMissingEmail]; ++ (NSError *)missingEmailErrorWithMessage:(nullable NSString *)message { + return [self errorWithCode:FIRAuthInternalErrorCodeMissingEmail message:message]; } + (NSError *)missingPhoneNumberErrorWithMessage:(nullable NSString *)message { diff --git a/Firebase/Auth/Source/RPCs/FIRAuthBackend.m b/Firebase/Auth/Source/RPCs/FIRAuthBackend.m index 2cfa516..8eca6d5 100644 --- a/Firebase/Auth/Source/RPCs/FIRAuthBackend.m +++ b/Firebase/Auth/Source/RPCs/FIRAuthBackend.m @@ -234,6 +234,12 @@ static NSString *const kExpiredActionCodeErrorMessage = @"EXPIRED_OOB_CODE"; */ static NSString *const kInvalidActionCodeErrorMessage = @"INVALID_OOB_CODE"; +/** @var kMissingEmailErrorMessage + @brief This is the error message the server will respond with if the email address is missing + during a "send password reset email" attempt. + */ +static NSString *const kMissingEmailErrorMessage = @"MISSING_EMAIL"; + /** @var kInvalidSenderEmailErrorMessage @brief This is the error message the server will respond with if the sender email is invalid during a "send password reset email" attempt. @@ -936,6 +942,10 @@ static id<FIRAuthBackendImplementation> gBackendImplementation; return [FIRAuthErrorUtils invalidActionCodeErrorWithMessage:serverDetailErrorMessage]; } + if ([shortErrorMessage isEqualToString:kMissingEmailErrorMessage]) { + return [FIRAuthErrorUtils missingEmailErrorWithMessage:serverDetailErrorMessage]; + } + if ([shortErrorMessage isEqualToString:kInvalidSenderEmailErrorMessage]) { return [FIRAuthErrorUtils invalidSenderErrorWithMessage:serverDetailErrorMessage]; } |