mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Improve behavior, when authorization fails
- register command should still be possible, to regain authorization - reset uuid after registering, otherwise the verify request will fail
This commit is contained in:
parent
9546a79308
commit
995de3ef5b
2 changed files with 16 additions and 14 deletions
|
@ -38,6 +38,7 @@ import org.asamk.signal.util.SecurityProvider;
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.freedesktop.dbus.DBusConnection;
|
import org.freedesktop.dbus.DBusConnection;
|
||||||
import org.freedesktop.dbus.exceptions.DBusException;
|
import org.freedesktop.dbus.exceptions.DBusException;
|
||||||
|
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
||||||
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -105,6 +106,12 @@ public class Main {
|
||||||
ts = m;
|
ts = m;
|
||||||
try {
|
try {
|
||||||
m.init();
|
m.init();
|
||||||
|
} catch (AuthorizationFailedException e) {
|
||||||
|
if (!"register".equals(ns.getString("command"))) {
|
||||||
|
// Register command should still be possible, if current authorization fails
|
||||||
|
System.err.println("Authorization failed, was the number registered elsewhere?");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Error loading state file: " + e.getMessage());
|
System.err.println("Error loading state file: " + e.getMessage());
|
||||||
return 2;
|
return 2;
|
||||||
|
|
|
@ -99,7 +99,6 @@ import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage
|
||||||
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
|
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
|
||||||
import org.whispersystems.signalservice.api.push.ContactTokenDetails;
|
import org.whispersystems.signalservice.api.push.ContactTokenDetails;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.EncapsulatedExceptions;
|
import org.whispersystems.signalservice.api.push.exceptions.EncapsulatedExceptions;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureException;
|
import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureException;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||||
|
@ -215,20 +214,15 @@ public class Manager implements Signal {
|
||||||
migrateLegacyConfigs();
|
migrateLegacyConfigs();
|
||||||
|
|
||||||
accountManager = getSignalServiceAccountManager();
|
accountManager = getSignalServiceAccountManager();
|
||||||
try {
|
if (account.isRegistered()) {
|
||||||
if (account.isRegistered()) {
|
if (accountManager.getPreKeysCount() < BaseConfig.PREKEY_MINIMUM_COUNT) {
|
||||||
if (accountManager.getPreKeysCount() < BaseConfig.PREKEY_MINIMUM_COUNT) {
|
refreshPreKeys();
|
||||||
refreshPreKeys();
|
account.save();
|
||||||
account.save();
|
}
|
||||||
}
|
if (account.getUuid() == null) {
|
||||||
if (account.getUuid() == null) {
|
account.setUuid(accountManager.getOwnUuid());
|
||||||
account.setUuid(accountManager.getOwnUuid());
|
account.save();
|
||||||
account.save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (AuthorizationFailedException e) {
|
|
||||||
System.err.println("Authorization failed, was the number registered elsewhere?");
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,6 +273,7 @@ public class Manager implements Signal {
|
||||||
createNewIdentity();
|
createNewIdentity();
|
||||||
}
|
}
|
||||||
account.setPassword(KeyUtils.createPassword());
|
account.setPassword(KeyUtils.createPassword());
|
||||||
|
account.setUuid(null);
|
||||||
accountManager = getSignalServiceAccountManager();
|
accountManager = getSignalServiceAccountManager();
|
||||||
|
|
||||||
if (voiceVerification) {
|
if (voiceVerification) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue