From 5358fc4f43ba5ca98307b0e988f46fca2fd291e0 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 28 Jan 2022 17:12:15 -0800 Subject: [PATCH] Use `setRegistrationLockFromAttributes` --- .../controllers/AccountController.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java index 21c07c267..3f50bea7d 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java @@ -359,7 +359,7 @@ public class AccountController { storedVerificationCode.flatMap(StoredVerificationCode::getTwilioVerificationSid) .ifPresent(smsSender::reportVerificationSucceeded); - Optional existingAccount = accounts.getByE164(number); + Optional existingAccount = accounts.getByE164(number); if (existingAccount.isPresent()) { verifyRegistrationLock(existingAccount.get(), accountAttributes.getRegistrationLock()); @@ -571,11 +571,6 @@ public class AccountController { Account account = disabledPermittedAuth.getAccount(); long deviceId = disabledPermittedAuth.getAuthenticatedDevice().getId(); - // temporary: For deterministic updates during the DynamoDB migration, use a fully parameterized registration lock - @Nullable final AuthenticationCredentials registrationLockCredentials = - Util.isEmpty(attributes.getRegistrationLock()) ? null - : new AuthenticationCredentials(attributes.getRegistrationLock()); - accounts.update(account, a -> { a.getDevice(deviceId).ifPresent(d -> { d.setFetchesMessages(attributes.getFetchesMessages()); @@ -586,15 +581,7 @@ public class AccountController { d.setUserAgent(userAgent); }); - // temporary: for deterministic updates during the DynamoDB migration, use a fully parameterized registration lock - // a.setRegistrationLockFromAttributes(attributes); - if (registrationLockCredentials != null) { - a.setRegistrationLock(registrationLockCredentials.getHashedAuthenticationToken(), - registrationLockCredentials.getSalt()); - } else { - a.setRegistrationLock(null, null); - } - + a.setRegistrationLockFromAttributes(attributes); a.setUnidentifiedAccessKey(attributes.getUnidentifiedAccessKey()); a.setUnrestrictedUnidentifiedAccess(attributes.isUnrestrictedUnidentifiedAccess()); a.setDiscoverableByPhoneNumber(attributes.isDiscoverableByPhoneNumber());