@RequestMapping("/login")
  public String login(String username, String password, HttpSession session) throws Exception {
    User user = users.findOneByUsername(username);

    if (user == null) {
      user = new User();
      user.username = username;
      user.password = PasswordHash.createHash(password);
      users.save(user);
    } else if (!PasswordHash.validatePassword(password, user.password)) {
      throw new Exception("Wrong password");
    }
    session.setAttribute("username", username);
    return "redirect:/";
  }
  @PostConstruct
  public void init() throws InvalidKeySpecException, NoSuchAlgorithmException {
    if (users.count() == 0) {
      User user = new User("admin", PasswordHash.createHash("admin"));
      users.save(user);
    }

    if (appointments.count() == 0) {
      User user = users.findOneByUsername("admin");
      appointments.save(
          new Appointment(user, "12", "14", "2015", "00", "00", "Headache", "House", "Holden"));
    }
  }