From 1301bfda93d2a6d948d5d6a4901ab92de2ab97f0 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Tue, 14 Apr 2026 12:23:17 -0400 Subject: [PATCH] Avoid blocking in an async context --- .../auth/PhoneVerificationTokenManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/auth/PhoneVerificationTokenManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/auth/PhoneVerificationTokenManager.java index 88dae7c92..d6d8232ca 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/auth/PhoneVerificationTokenManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/auth/PhoneVerificationTokenManager.java @@ -108,14 +108,19 @@ public class PhoneVerificationTokenManager { } } - private void verifyByRecoveryPassword(final ContainerRequestContext requestContext, final String number, final byte[] recoveryPassword) - throws InterruptedException { + private void verifyByRecoveryPassword(final ContainerRequestContext requestContext, + final String number, + final byte[] recoveryPassword) throws InterruptedException { + if (!registrationRecoveryChecker.checkRegistrationRecoveryAttempt(requestContext, number)) { throw new ForbiddenException("recoveryPassword couldn't be verified"); } + try { - final boolean verified = registrationRecoveryPasswordsManager.verify(phoneNumberIdentifiers.getPhoneNumberIdentifier(number).join(), recoveryPassword) + final boolean verified = phoneNumberIdentifiers.getPhoneNumberIdentifier(number) + .thenCompose(phoneNumberIdentifier -> registrationRecoveryPasswordsManager.verify(phoneNumberIdentifier, recoveryPassword)) .get(VERIFICATION_TIMEOUT_SECONDS, TimeUnit.SECONDS); + if (!verified) { throw new ForbiddenException("recoveryPassword couldn't be verified"); } @@ -123,5 +128,4 @@ public class PhoneVerificationTokenManager { throw new ServerErrorException(Response.Status.SERVICE_UNAVAILABLE); } } - }