private boolean login(LoginMessage loginMessage, Connection userConnection) {
    boolean successful = false;
    LoginResponseMessage responseMessage;
    try {
      UserRecord userRecord = databaseOperations.getUserRecord(loginMessage.getUsername());
      if (userRecord == null) { // user doens't exist
        responseMessage = new LoginResponseMessage(false, INCORRECT_USERNAME, null);
      }
      else {
        String correctPassword = userRecord.getPassword();
        String inputPassword = new String(loginMessage.getPassword());
        if (correctPassword.compareTo(inputPassword) != 0) { // incorrect password
          responseMessage = new LoginResponseMessage(false, INCORRECT_PASSWORD, null);
        }
        else {
          com.is.chatmultimedia.models.User userData = databaseOperations.getUserData(loginMessage.getUsername());
          List<User> onlineFriends = getOnlineFriendsForUser(userData);
          responseMessage = new LoginResponseMessage(true, LOGIN_SUCCESSFUL, userData);
          notifyFriendsThatUserCameOnline(loginMessage.getUsername(), onlineFriends);
          // save user as logged in
          User user = new User(loginMessage.getUsername(), userConnection);
          userManager.addUser(user);
          // TEST MESSAGE
          System.out.println("User - " + user.getUsername() + " - logged in! Logged in users ("
              + userManager.getNumberOfUsers() + "): " + userManager.getListOfUsers());
          successful = true;
        }
      }
      // write response to user
      writeResponse(responseMessage, userConnection);
      if (successful) { // send new logged in user any pending friend requests
        List<FriendRequest> requests = databaseOperations.getAllFriendRequestsForUser(loginMessage.getUsername());
        FriendRequestMessage request;
        for (FriendRequest it : requests) {
          request = new FriendRequestMessage(it);
          writeResponse(request, userConnection);
        }
      }
      return true;
    }
    catch (SQLException e) {
      // database query failed
    }
    return false;
  }