<commit_before><?php
  namespace controller;

  require_once("src/model/DAL/MemberRepository.php");
  require_once("src/model/MemberModel.php");
  require_once("src/view/Member.php");
  require_once("src/helper/Misc.php");

  class Member {
    private $model;
    private $view;
    private $MemberRepository;
    private $misc;

    public function __construct() {
      $this->model = new \model\MemberModel();
      $this->MemberRepository = new \DAL\MemberRepository();
      $this->view   = new \view\Member();
      $this->misc = new \helper\Misc();
    }

    public function addMember() {
      if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
        try {
          $newMember = $this->view->getFormData();

          $this->MemberRepository->addMember($newMember);

          $this->misc->setAlert("Registrering av ny användare lyckades.");
          //$_SESSION["Member_username"] = $newUser->getName();

          // TODO Log the user in

          \view\Navigation::redirectHome();
        } catch (\Exception $e) {
          $this->misc->setAlert($e->getMessage());
          return $this->view->getForm();
        }
      } else {
        return $this->view->getForm();
      }
    }

    public function logIn() {
      if ($this->view->didMemberPressLogin()) {
        // Get the form data and log the user in
        $member = $this->view->getFormData();
        $this->model->logIn($member);

        // Redirect home
        \view\Navigation::redirectHome();
      }<commit_msg>Now autologin when registering<commit_after><?php
  namespace controller;

  require_once("src/model/DAL/MemberRepository.php");
  require_once("src/model/MemberModel.php");
  require_once("src/view/Member.php");
  require_once("src/helper/Misc.php");

  class Member {
    private $model;
    private $view;
    private $MemberRepository;
    private $misc;

    public function __construct() {
      $this->model = new \model\MemberModel();
      $this->MemberRepository = new \DAL\MemberRepository();
      $this->view   = new \view\Member();
      $this->misc = new \helper\Misc();
    }

    public function addMember() {
      if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
        try {
          $newMember = $this->view->getFormData();

          $this->MemberRepository->addMember($newMember);

          $this->misc->setAlert("Registrering av ny användare lyckades.");

          $this->model->logIn($newMember);

          \view\Navigation::redirectHome();
        } catch (\Exception $e) {
          $this->misc->setAlert($e->getMessage());
          return $this->view->getForm();
        }
      } else {
        return $this->view->getForm();
      }
    }

    public function logIn() {
      if ($this->view->didMemberPressLogin()) {
        // Get the form data and log the user in
        $member = $this->view->getFormData();
        $this->model->logIn($member);

        // Redirect home
        \view\Navigation::redirectHome();
      }
{'fraction_non_alphanumeric': 0.1609543010752688, 'fraction_numerical': 0.0, 'mean_word_length': 2.4900351699882766, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 52, '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': '2328535', 'n_tokens_mistral': 887, 'n_tokens_neox': 862, 'n_words': 165}