Ejemplo n.º 1
0
  public void run() {
    while (true) {
      String command = io.readLine(">");

      if (command.isEmpty()) {
        break;
      }

      if (command.equals("new")) {
        String[] usernameAndPasword = ask();
        if (auth.createUser(usernameAndPasword[0], usernameAndPasword[1])) {
          io.print("new user registered");
        } else {
          io.print("new user not registered");
        }

      } else if (command.equals("login")) {
        String[] usernameAndPasword = ask();
        if (auth.logIn(usernameAndPasword[0], usernameAndPasword[1])) {
          io.print("logged in");
        } else {
          io.print("wrong username or password");
        }
      }
    }
  }
Ejemplo n.º 2
0
 public String[] ask() {
   String[] userPwd = new String[2];
   userPwd[0] = io.readLine("username:"******"password:");
   return userPwd;
 }