]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/commands/VerifyCommand.java
1 package org
.asamk
.signal
.commands
;
3 import net
.sourceforge
.argparse4j
.inf
.Namespace
;
4 import net
.sourceforge
.argparse4j
.inf
.Subparser
;
5 import org
.asamk
.signal
.manager
.Manager
;
6 import org
.whispersystems
.signalservice
.internal
.push
.LockedException
;
8 import java
.io
.IOException
;
10 public class VerifyCommand
implements LocalCommand
{
13 public void attachToSubparser(final Subparser subparser
) {
14 subparser
.addArgument("verificationCode")
15 .help("The verification code you received via sms or voice call.");
16 subparser
.addArgument("-p", "--pin")
17 .help("The registration lock PIN, that was set by the user (Optional)");
21 public int handleCommand(final Namespace ns
, final Manager m
) {
22 if (!m
.userHasKeys()) {
23 System
.err
.println("User has no keys, first call register.");
26 if (m
.isRegistered()) {
27 System
.err
.println("User registration is already verified");
31 String verificationCode
= ns
.getString("verificationCode");
32 String pin
= ns
.getString("pin");
33 m
.verifyAccount(verificationCode
, pin
);
35 } catch (LockedException e
) {
36 System
.err
.println("Verification failed! This number is locked with a pin. Hours remaining until reset: " + (e
.getTimeRemaining() / 1000 / 60 / 60));
37 System
.err
.println("Use '--pin PIN_CODE' to specify the registration lock PIN");
39 } catch (IOException e
) {
40 System
.err
.println("Verify error: " + e
.getMessage());