]>
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
;
6 import org
.asamk
.signal
.manager
.Manager
;
7 import org
.whispersystems
.signalservice
.internal
.push
.LockedException
;
9 import java
.io
.IOException
;
11 public class VerifyCommand
implements LocalCommand
{
14 public void attachToSubparser(final Subparser subparser
) {
15 subparser
.addArgument("verificationCode")
16 .help("The verification code you received via sms or voice call.");
17 subparser
.addArgument("-p", "--pin")
18 .help("The registration lock PIN, that was set by the user (Optional)");
22 public int handleCommand(final Namespace ns
, final Manager m
) {
23 if (!m
.userHasKeys()) {
24 System
.err
.println("User has no keys, first call register.");
27 if (m
.isRegistered()) {
28 System
.err
.println("User registration is already verified");
32 String verificationCode
= ns
.getString("verificationCode");
33 String pin
= ns
.getString("pin");
34 m
.verifyAccount(verificationCode
, pin
);
36 } catch (LockedException e
) {
37 System
.err
.println("Verification failed! This number is locked with a pin. Hours remaining until reset: " + (e
.getTimeRemaining() / 1000 / 60 / 60));
38 System
.err
.println("Use '--pin PIN_CODE' to specify the registration lock PIN");
40 } catch (IOException e
) {
41 System
.err
.println("Verify error: " + e
.getMessage());