Exemplo n.º 1
0
  private String getStudentInfo(String username) {
    Student stu = studentRepository.findByUsername(username);
    String ret =
        "Student username: "******", password: "******", name: "
            + stu.getFirstName()
            + " "
            + stu.getLastName()
            + "\n";

    return ret;
  }
Exemplo n.º 2
0
  // Return error string if there is an error.  Return empty string if there is no error.
  public String login(String username, String password) {
    String ret = "";
    String errorMsg = "Please enter your Username and Password.";
    String errorMsg2 = "The username doesn't exist.";
    String errorMsg3 = "Wrong password!";

    if (username == null
        || (username != null && username.isEmpty())
        || password == null
        || (password != null && password.isEmpty())) {
      ret = errorMsg;
      return ret;
    }

    Student stu = studentRepository.findByUsername(username);
    if (stu == null) { // can't find username
      ret = errorMsg2;
    } else if (!stu.getPassword().equals(password)) { // password doesn't match
      ret = errorMsg3;
    }

    return ret;
  }