<commit_before>  <?php
  require_once(dirname(__DIR__)."/_config/autoloader.php");
  require_once(dirname(__DIR__)."/inc/utility.php");
  require_once(dirname(__DIR__)."/data/UserDAO.php");

  class Authentication {
    private $output;
    private $user_dao;

    public function __construct() {
      $this->output = new Message();
      $this->user_dao = new UserDAO();
    }
    // this class contains many early return points, bad
    // but necessary
    public function login($role = User::BACKER_ROLE) {
      $user_name = (filter_input(INPUT_POST, "login_id", FILTER_SANITIZE_STRING));
      $password = (filter_input(INPUT_POST, "login_pass", FILTER_UNSAFE_RAW));
      $data = compact("user_name", "password");

      if ($this->isEmpty($data)) {
        $this->output->putFailure("Bad input");
        return $this->output;
      }
      // try to retrieve user from database
      $user = $this->user_dao->getUserByNameOrEmail($user_name, $role);

      if (!$user) {
        // user does not exist
        $this->output->putFailure("Did you forget your login name or password?");
        return $this->output;
      }

      // verify password
      if (!password_verify($password, $user->getPassword())) {
        $this->output->putFailure("Did you forget your login name or password?");
      }

      $this->setSessionData($user);
      $this->output->putinfo("Login sucessful");
      $this->output->putData('user_name' , $_SESSION['user_name']);
      $this->output->putData('user_id', $_SESSION['user_id']);
      $this->output->putData('first_name', $user->getFirstname());
      $this->output->putData('last_name', $user->getLastname());
      $this->output->putData('profile_pic' , $user->profile_pic);

      return $this->output;
    }<commit_msg>fix login problem<commit_after>  <?php
  require_once(dirname(__DIR__)."/_config/autoloader.php");
  require_once(dirname(__DIR__)."/inc/utility.php");
  require_once(dirname(__DIR__)."/data/UserDAO.php");

  class Authentication {
    private $output;
    private $user_dao;

    public function __construct() {
      $this->output = new Message();
      $this->user_dao = new UserDAO();
    }
    // this class contains many early return points, bad
    // but necessary
    public function login($role = User::BACKER_ROLE) {
      $user_name = (filter_input(INPUT_POST, "login_id", FILTER_SANITIZE_STRING));
      $password = (filter_input(INPUT_POST, "login_pass", FILTER_UNSAFE_RAW));
      $data = compact("user_name", "password");

      if ($this->isEmpty($data)) {
        $this->output->putFailure("Bad input");
        return $this->output;
      }
      // try to retrieve user from database
      $user = $this->user_dao->getUserByNameOrEmail($user_name, $role);

      if (!$user) {
        // user does not exist
        $this->output->putFailure("Did you forget your login name or password?");
        return $this->output;
      }

      // verify password
      if (!password_verify($password, $user->getPassword())) {
        $this->output->putFailure("Did you forget your login name or password?");
        return $this->output;

      }

      $this->setSessionData($user);
      $this->output->putinfo("Login sucessful");
      $this->output->putData('user_name' , $_SESSION['user_name']);
      $this->output->putData('user_id', $_SESSION['user_id']);
      $this->output->putData('first_name', $user->getFirstname());
      $this->output->putData('last_name', $user->getLastname());
      $this->output->putData('profile_pic' , $user->profile_pic);

      return $this->output;
    }
{'fraction_non_alphanumeric': 0.1654093322157027, 'fraction_numerical': 0.0, 'mean_word_length': 3.297719087635054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 66, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1184165', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1091, 'n_words': 212}