Commit 9be18958 authored by Finn Herzfeld's avatar Finn Herzfeld 🌵

Merge branch 'feature/captcha-support' into 'master'

Feature/captcha support

See merge request !100
parents e35789ac d1591adf
Pipeline #3365 passed with stages
in 5 minutes and 53 seconds
......@@ -107,6 +107,7 @@ Begins the process of registering a new number on signal for use with signald. P
| Field | Type | Required? | Description |
|-------|------|-----------|-------------|
| `username` | string | yes | The phone number to register |
| `captcha` | string | no | The captcha value to use, if you get `CaptchaRequiredException` when trying to register. Unlcear if this option works, see [this issue](https://gitlab.com/thefinn93/signald/issues/8), please update it if you are unable to register without a captcha, so we can know if it works.
| `voice` | boolean | no | Indicates if the verification code should be sent via a phone call. If `false` or not set the verification is done via SMS |
......
......@@ -42,6 +42,7 @@ class JsonRequest {
public int expiresInSeconds;
public String fingerprint;
public ContactInfo contact;
public String captcha;
public String name;
JsonRequest() {}
......
......@@ -482,14 +482,18 @@ class Manager {
}
public void register(boolean voiceVerification) throws IOException {
register(voiceVerification, Optional.<String>absent());
}
public void register(boolean voiceVerification, Optional<String> captcha) throws IOException {
password = Util.getSecret(18);
accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, USER_AGENT, sleepTimer);
if (voiceVerification) {
accountManager.requestVoiceVerificationCode(Locale.getDefault(), Optional.<String>absent(), Optional.<String>absent()); // TODO: Allow requester to set the locale
accountManager.requestVoiceVerificationCode(Locale.getDefault(), captcha, Optional.absent()); // TODO: Allow requester to set the locale
} else {
accountManager.requestSmsVerificationCode(true, Optional.<String>absent(), Optional.<String>absent()); // TODO: Allow requester to set challenge
accountManager.requestSmsVerificationCode(true, captcha, Optional.absent()); // TODO: Allow requester to set challenge
}
registered = false;
......
......@@ -305,7 +305,7 @@ public class SocketHandler implements Runnable {
m.createNewIdentity();
}
logger.info("Registering (voice: " + voice + ")");
m.register(voice);
m.register(voice, Optional.fromNullable(request.captcha));
this.reply("verification_required", new JsonAccount(m), request.id);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment