Ejemplo n.º 1
0
  @Override
  public boolean createUser(Users user, UsersInfo usersInfo, Session session) {

    if (!Utils.isExists(user.getUsername())) {
      user.setPassword(Utils.encryptPass(user.getPassword()));
      usersInfo.setUsers(user);
      session.save(user);

      return true;
    }

    return false;
  }
Ejemplo n.º 2
0
  @Override
  public boolean updateUserInfo(Users user, Session session) {
    boolean result = false;
    if (Utils.isAdmin()) {

      if (!Utils.isExists(user.getUsername())) {
        LOGGER.error("Couldn't update user's info of user with username " + user.getUsername());
      } else {
        session.update(user);
        result = true;
      }
    } else {

      if (!Utils.isExists(user.getUsername()) || !isUserLoggedIn(user.getUsername())) {
        LOGGER.error("Couldn't update user's info of user with username " + user.getUsername());
      } else {
        session.update(user.getUsersInfo());
        result = true;
      }
    }

    return result;
  }