Merge branch 'charlesmchen/registerVsRateLimit'

pull/1/head
Matthew Chen 7 years ago
commit 471a194764

@ -302,29 +302,18 @@ NS_ASSUME_NONNULL_BEGIN
- (void)presentAlertWithVerificationError:(NSError *)error - (void)presentAlertWithVerificationError:(NSError *)error
{ {
UIAlertController *alertController; UIAlertController *alert;
// In the case of the "rate limiting" error, we want to show the alert = [UIAlertController
// "recovery suggestion", not the error's "description." alertControllerWithTitle:NSLocalizedString(@"REGISTRATION_VERIFICATION_FAILED_TITLE", @"Alert view title")
if ([error.domain isEqualToString:TSNetworkManagerDomain] && message:error.localizedDescription
error.code == 413) { preferredStyle:UIAlertControllerStyleAlert];
alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"REGISTRATION_VERIFICATION_FAILED_TITLE", [alert addAction:[UIAlertAction actionWithTitle:CommonStrings.dismissButton
@"Alert view title") style:UIAlertActionStyleDefault
message:error.localizedRecoverySuggestion handler:^(UIAlertAction *action) {
preferredStyle:UIAlertControllerStyleAlert]; [_challengeTextField becomeFirstResponder];
} else { }]];
alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"REGISTRATION_VERIFICATION_FAILED_TITLE",
@"Alert view title") [self presentViewController:alert animated:YES completion:nil];
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
}
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.dismissButton
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[_challengeTextField becomeFirstResponder];
}];
[alertController addAction:dismissAction];
[self presentViewController:alertController animated:YES completion:nil];
} }
- (NSString *)validationCodeFromTextField { - (NSString *)validationCodeFromTextField {

@ -1444,9 +1444,12 @@
/* Alert view title */ /* Alert view title */
"REGISTRATION_VERIFICATION_FAILED_TITLE" = "Verification Failed"; "REGISTRATION_VERIFICATION_FAILED_TITLE" = "Verification Failed";
/* Alert body, during registration */ /* Error message indicating that registration failed due to a missing or incorrect verification code. */
"REGISTRATION_VERIFICATION_FAILED_WRONG_CODE_DESCRIPTION" = "The numbers you submitted don't match what we sent. Want to double check?"; "REGISTRATION_VERIFICATION_FAILED_WRONG_CODE_DESCRIPTION" = "The numbers you submitted don't match what we sent. Want to double check?";
/* Error message indicating that registration failed due to a missing or incorrect 2FA PIN. */
"REGISTRATION_VERIFICATION_FAILED_WRONG_PIN" = "Incorrect Registration Lock PIN.";
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"REGISTRATION_VERIFY_DEVICE" = "Activate This Device"; "REGISTRATION_VERIFY_DEVICE" = "Activate This Device";

@ -386,24 +386,37 @@ NSString *const TSAccountManager_ServerSignalingKey = @"TSStorageServerSignaling
if (!IsNSErrorNetworkFailure(error)) { if (!IsNSErrorNetworkFailure(error)) {
OWSProdError([OWSAnalyticsEvents accountsErrorVerifyAccountRequestFailed]); OWSProdError([OWSAnalyticsEvents accountsErrorVerifyAccountRequestFailed]);
} }
OWSAssert([error.domain isEqualToString:TSNetworkManagerDomain]);
DDLogWarn(@"%@ Error verifying code: %@", self.logTag, error.debugDescription); DDLogWarn(@"%@ Error verifying code: %@", self.logTag, error.debugDescription);
switch (error.code) { switch (error.code) {
case 403: { case 403: {
NSError *userError = OWSErrorWithCodeDescription(OWSErrorCodeUserError, NSError *userError = OWSErrorWithCodeDescription(OWSErrorCodeUserError,
NSLocalizedString(@"REGISTRATION_VERIFICATION_FAILED_WRONG_CODE_DESCRIPTION", NSLocalizedString(@"REGISTRATION_VERIFICATION_FAILED_WRONG_CODE_DESCRIPTION",
"Alert body, during registration")); "Error message indicating that registration failed due to a missing or incorrect "
"verification code."));
failureBlock(userError);
break;
}
case 413: {
// In the case of the "rate limiting" error, we want to show the
// "recovery suggestion", not the error's "description."
NSError *userError
= OWSErrorWithCodeDescription(OWSErrorCodeUserError, error.localizedRecoverySuggestion);
failureBlock(userError); failureBlock(userError);
break; break;
} }
case 423: { case 423: {
DDLogError(@"%@ 2FA PIN required: %ld", self.logTag, error.code); DDLogError(@"%@ 2FA PIN required: %ld", self.logTag, error.code);
NSError *error = OWSErrorWithCodeDescription( NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeRegistrationMissing2FAPIN,
OWSErrorCodeRegistrationMissing2FAPIN, @"Registration missing 2FA PIN."); NSLocalizedString(@"REGISTRATION_VERIFICATION_FAILED_WRONG_PIN",
"Error message indicating that registration failed due to a missing or incorrect 2FA PIN."));
failureBlock(error); failureBlock(error);
break; break;
} }
default: { default: {
DDLogError(@"%@ verifying code failed with unhandled error: %@", self.logTag, error); DDLogError(@"%@ verifying code failed with unknown error: %@", self.logTag, error);
failureBlock(error); failureBlock(error);
break; break;
} }

Loading…
Cancel
Save