Prevent GV2 operations after becoming unregistered.
This commit is contained in:
parent
938b24f623
commit
309e33016a
2 changed files with 25 additions and 0 deletions
|
@ -57,6 +57,10 @@ public final class GroupsV2Authorization {
|
|||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
private static int currentTimeDays() {
|
||||
return (int) TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis());
|
||||
}
|
||||
|
|
|
@ -15,8 +15,11 @@ import androidx.core.app.NotificationCompat;
|
|||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.zkgroup.profiles.ProfileKey;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.backup.BackupProtos;
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraintObserver;
|
||||
import org.thoughtcrime.securesms.keyvalue.SettingsValues;
|
||||
|
@ -472,6 +475,10 @@ public class TextSecurePreferences {
|
|||
if (previous != value) {
|
||||
Recipient.self().live().refresh();
|
||||
}
|
||||
|
||||
if (value) {
|
||||
clearLocalCredentials(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isUnauthorizedRecieved(Context context) {
|
||||
|
@ -927,6 +934,10 @@ public class TextSecurePreferences {
|
|||
if (previous != registered) {
|
||||
Recipient.self().live().refresh();
|
||||
}
|
||||
|
||||
if (previous && !registered) {
|
||||
clearLocalCredentials(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isShowInviteReminders(Context context) {
|
||||
|
@ -1291,6 +1302,16 @@ public class TextSecurePreferences {
|
|||
}
|
||||
}
|
||||
|
||||
private static void clearLocalCredentials(Context context) {
|
||||
TextSecurePreferences.setPushServerPassword(context, Util.getSecret(18));
|
||||
|
||||
ProfileKey newProfileKey = ProfileKeyUtil.createNew();
|
||||
Recipient self = Recipient.self();
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileKey(self.getId(), newProfileKey);
|
||||
|
||||
ApplicationDependencies.getGroupsV2Authorization().clear();
|
||||
}
|
||||
|
||||
// NEVER rename these -- they're persisted by name
|
||||
public enum MediaKeyboardMode {
|
||||
EMOJI, STICKER, GIF
|
||||
|
|
Loading…
Add table
Reference in a new issue