Ejemplo n.º 1
0
  private void doLogin() throws RuntimeException {

    Application application = Application.getInstance();

    UserDAO dao = new UserDAO();
    User user = dao.findUser(Integer.valueOf(userId));
    if (!user.getPassword().equals(PasswordHasher.hashPassword(userPassword))) {
      throw new RuntimeException(POSConstants.WRONG_PASSWORD);
    }

    Shift currentShift = ShiftUtil.getCurrentShift();
    if (currentShift == null) {
      throw new RuntimeException(POSConstants.NO_SHIFT_CONFIGURED);
    }

    adjustUserShift(user, currentShift);

    application.setCurrentUser(user);
    application.setCurrentShift(currentShift);

    application.getRootView().showView(SwitchboardView.VIEW_NAME);
  }