public interface RegistrationManager extends Closeable {
void register(
- boolean voiceVerification, String captcha
+ boolean voiceVerification, String captcha, final boolean forceRegister
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethoNotAvailableException;
void verifyAccount(
@Override
public void register(
- boolean voiceVerification, String captcha
+ boolean voiceVerification, String captcha, final boolean forceRegister
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethoNotAvailableException {
if (account.isRegistered()
&& account.getServiceEnvironment() != null
}
try {
- final var recoveryPassword = account.getRecoveryPassword();
- if (recoveryPassword != null && account.isPrimaryDevice() && attemptReregisterAccount(recoveryPassword)) {
- return;
+ if (!forceRegister) {
+ if (account.isRegistered()) {
+ throw new IOException("Account is already registered");
+ }
+
+ if (account.getAci() != null && attemptReactivateAccount()) {
+ return;
+ }
}
- if (account.getAci() != null && attemptReactivateAccount()) {
+ final var recoveryPassword = account.getRecoveryPassword();
+ if (recoveryPassword != null && account.isPrimaryDevice() && attemptReregisterAccount(recoveryPassword)) {
return;
}
voiceVerification,
captcha);
NumberVerificationUtils.requestVerificationCode(accountManager, sessionId, voiceVerification);
+ account.setRegistered(false);
} catch (DeprecatedVersionException e) {
logger.debug("Signal-Server returned deprecated version exception", e);
throw e;
The verification should be done over voice, not SMS.
Voice verification only works if an SMS verification has been attempted before.
-*--captcha*::
+*--captcha* CAPTCHA::
The captcha token, required if registration failed with a captcha required error.
To get the token, go to https://signalcaptchas.org/registration/generate.html
For the staging environment, use: https://signalcaptchas.org/staging/registration/generate.html
After solving the captcha, right-click on the "Open Signal" link and copy the link.
+*--reregister*::
+Register even if account is already registered.
+
=== verify
Verify the number using the code received via SMS or voice.
.action(Arguments.storeTrue());
subparser.addArgument("--captcha")
.help("The captcha token, required if registration failed with a captcha required error.");
+ subparser.addArgument("--reregister")
+ .action(Arguments.storeTrue())
+ .help("Register even if account is already registered");
}
@Override
public void handleCommand(final Namespace ns, final RegistrationManager m) throws CommandException {
final boolean voiceVerification = Boolean.TRUE.equals(ns.getBoolean("voice"));
final var captcha = ns.getString("captcha");
+ final var reregister = Boolean.TRUE.equals(ns.getBoolean("reregister"));
- register(m, voiceVerification, captcha);
+ register(m, voiceVerification, captcha, reregister);
}
@Override
public void handleCommand(
final RegistrationParams request, final RegistrationManager m, final JsonWriter jsonWriter
) throws CommandException {
- register(m, Boolean.TRUE.equals(request.voice()), request.captcha());
+ register(m, Boolean.TRUE.equals(request.voice()), request.captcha(), Boolean.TRUE.equals(request.reregister()));
}
private void register(
- final RegistrationManager m, final boolean voiceVerification, final String captcha
+ final RegistrationManager m, final boolean voiceVerification, final String captcha, final boolean reregister
) throws CommandException {
try {
- m.register(voiceVerification, captcha);
+ m.register(voiceVerification, captcha, reregister);
} catch (RateLimitException e) {
final var message = CommandUtil.getRateLimitMessage(e);
throw new RateLimitErrorException(message, e);
}
}
- public record RegistrationParams(Boolean voice, String captcha) {}
+ public record RegistrationParams(Boolean voice, String captcha, Boolean reregister) {}
}
@Override
public void register(
- final boolean voiceVerification, final String captcha
+ final boolean voiceVerification, final String captcha, final boolean forceRegister
) throws IOException, CaptchaRequiredException {
+ if (forceRegister) {
+ throw new UnsupportedOperationException();
+ }
if (captcha == null) {
signalControl.register(number, voiceVerification);
} else {
"Invalid account (phone number), make sure you include the country code.");
}
try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) {
- registrationManager.register(voiceVerification, captcha);
+ registrationManager.register(voiceVerification, captcha, false);
} catch (RateLimitException e) {
String message = "Rate limit reached";
throw new SignalControl.Error.Failure(message);