<commit_before><?php


namespace App\Controllers;


use App\Models\Project;
use App\Models\Task;
use App\Models\User;
use Core\Helpers\Date;

class TasksController extends AppController
{
    public $hasModel = false;

    public function discover($step)
    {
        $d['step'] = $step;
        if ($step == 0) {
            $this->Session->delete("hasProject");
            $this->Session->delete("task-errors");
            $this->Session->delete("project-errors");
            $this->_createAndLogFakeUser();
        } elseif ($step == 1) {
        } elseif ($step == 2) {
            $d['projects'] = (new Project())->getAll()->recived_data;
        }
        
        return $this->set($d);
    }

    public function createFromDiscover()
    {
        if (!$this->Request->isPost) {
            $this->Session->setFlash("Mauvaise methode !", "error");
        } else {
            $task = new Task();
            if ($task->validate($this->Request->data)) {
                $task->data = $this->Request->data;
                $task->setHeaders()->store();
                $this->Session->setFlash("La tâche a bien été ajoutée", "success");
                $this->Session->write("discoverCompleted", true);
                $this->redirect("decouvrir/2");
            } else {
                $this->Session->write("task-errors", $task->getErrors());
                $this->Session->setFlash("Le titre de la tâche n'est pas valide !", 'error');
            }
        }
        $this->redirect("decouvrir/1");
    }

    private function _createAndLogFakeUser()
    {
        $fakeUser = new User([
            "login" => uniqid("fake-"),
            "password" => "<PASSWORD>"
        ]);
        $fakeUser->store()->connect();
        $this->Session->write("usertoken", $fakeUser->recived_data->data->user_token);
        $this->Session->write("userid", $fakeUser->recived_data->data->user_id);
    }

    public function user_add()
    {
        
    }

    public function user_store()
    {
        
    }
}<commit_msg>set username in session<commit_after><?php


namespace App\Controllers;


use App\Models\Project;
use App\Models\Task;
use App\Models\User;
use Core\Helpers\Date;

class TasksController extends AppController
{
    public $hasModel = false;

    public function discover($step)
    {
        $d['step'] = $step;
        if ($step == 0) {
            $this->Session->delete("hasProject");
            $this->Session->delete("task-errors");
            $this->Session->delete("project-errors");
            $this->_createAndLogFakeUser();
        } elseif ($step == 1) {
        } elseif ($step == 2) {
            $d['projects'] = (new Project())->getAll()->recived_data;
        }
        
        return $this->set($d);
    }

    public function createFromDiscover()
    {
        if (!$this->Request->isPost) {
            $this->Session->setFlash("Mauvaise methode !", "error");
        } else {
            $task = new Task();
            if ($task->validate($this->Request->data)) {
                $task->data = $this->Request->data;
                $task->setHeaders()->store();
                $this->Session->setFlash("La tâche a bien été ajoutée", "success");
                $this->Session->write("discoverCompleted", true);
                $this->redirect("decouvrir/2");
            } else {
                $this->Session->write("task-errors", $task->getErrors());
                $this->Session->setFlash("Le titre de la tâche n'est pas valide !", 'error');
            }
        }
        $this->redirect("decouvrir/1");
    }

    private function _createAndLogFakeUser()
    {
        $fakeUser = new User([
            "login" => uniqid("fake-"),
            "password" => "<PASSWORD>"
        ]);
        $fakeUser->store()->connect();
        $this->Session->write("usertoken", $fakeUser->recived_data->data->user_token);
        $this->Session->write("userid", $fakeUser->recived_data->data->user_id);
        $this->Session->write("username", $fakeUser->recived_data->data->user_login);
    }

    public function user_add()
    {
        
    }

    public function user_store()
    {
        
    }
}
{'fraction_non_alphanumeric': 0.17188252286952335, 'fraction_numerical': 0.002407318247472316, 'mean_word_length': 2.021818181818182, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 104, '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': '4209719', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1212, 'n_words': 209}