Merge branch 'charlesmchen/codeVerificationPromise'

pull/1/head
Matthew Chen 7 years ago
commit ca2ab587a5

@ -281,39 +281,39 @@ NS_ASSUME_NONNULL_BEGIN
[self startActivityIndicator]; [self startActivityIndicator];
OWSProdInfo([OWSAnalyticsEvents registrationRegisteringCode]); OWSProdInfo([OWSAnalyticsEvents registrationRegisteringCode]);
__weak CodeVerificationViewController *weakSelf = self; __weak CodeVerificationViewController *weakSelf = self;
[self.accountManager registerWithVerificationCode:[self validationCodeFromTextField] pin:nil] [[self.accountManager registerWithVerificationCode:[self validationCodeFromTextField] pin:nil]
.then(^{ .then(^{
OWSProdInfo([OWSAnalyticsEvents registrationRegisteringSubmittedCode]); OWSProdInfo([OWSAnalyticsEvents registrationRegisteringSubmittedCode]);
OWSLogInfo(@"Successfully registered Signal account."); OWSLogInfo(@"Successfully registered Signal account.");
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf stopActivityIndicator]; [weakSelf stopActivityIndicator];
[weakSelf verificationWasCompleted]; [weakSelf verificationWasCompleted];
}); });
}) })
.catch(^(NSError *error) { .catch(^(NSError *error) {
OWSLogError(@"error: %@, %@, %zd", [error class], error.domain, error.code); OWSLogError(@"error: %@, %@, %zd", [error class], error.domain, error.code);
OWSProdInfo([OWSAnalyticsEvents registrationRegistrationFailed]); OWSProdInfo([OWSAnalyticsEvents registrationRegistrationFailed]);
OWSLogError(@"error verifying challenge: %@", error); OWSLogError(@"error verifying challenge: %@", error);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf stopActivityIndicator]; [weakSelf stopActivityIndicator];
if ([error.domain isEqualToString:OWSSignalServiceKitErrorDomain] if ([error.domain isEqualToString:OWSSignalServiceKitErrorDomain]
&& error.code == OWSErrorCodeRegistrationMissing2FAPIN) { && error.code == OWSErrorCodeRegistrationMissing2FAPIN) {
CodeVerificationViewController *strongSelf = weakSelf; CodeVerificationViewController *strongSelf = weakSelf;
if (!strongSelf) { if (!strongSelf) {
return; return;
}
OWSLogInfo(@"Showing 2FA registration view.");
OWS2FARegistrationViewController *viewController = [OWS2FARegistrationViewController new];
viewController.verificationCode = strongSelf.validationCodeFromTextField;
[strongSelf.navigationController pushViewController:viewController animated:YES];
} else {
[weakSelf presentAlertWithVerificationError:error];
[weakSelf.challengeTextField becomeFirstResponder];
} }
OWSLogInfo(@"Showing 2FA registration view."); });
OWS2FARegistrationViewController *viewController = [OWS2FARegistrationViewController new]; }) retainUntilComplete];
viewController.verificationCode = strongSelf.validationCodeFromTextField;
[strongSelf.navigationController pushViewController:viewController animated:YES];
} else {
[weakSelf presentAlertWithVerificationError:error];
[weakSelf.challengeTextField becomeFirstResponder];
}
});
});
} }
- (void)verificationWasCompleted - (void)verificationWasCompleted

Loading…
Cancel
Save