<commit_before><?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Home extends Easol_Controller {


    protected function accessRules(){
        return [
            "index"     =>  "*",
            "logout"    =>  "@",
            "accessdenied"  =>  "@"
        ];
    }
    /**
     * index page
     */
    public function index()
	{
        if($this->session->userdata('logged_in')== true)
        {
            return redirect('/dashboard');
        }

        if(isset($_POST['login']) && $data=$this->input->post('login')) {

            $this->load->model('entities/edfi/Edfi_Staff','Edfi_Staff');
            /* @var $this->Staff Edfi_Staff */
            // = $this->Edfi_Staff->findOne(['LoginId' => $data['username']]);
            $staff = $this->Edfi_Staff->hydrate($this->Edfi_Staff->findOne(['LoginId' => $data['username']]));
            if($staff) {
                $this->load->model('entities/easol/Easol_StaffAuthentication','easol_authentication');
                $authentication=$this->easol_authentication->findOne(['StaffUSI' => $staff->StaffUSI]);

                if($authentication && $authentication->Password== sha1($data['password'])){
                    $this->session->sess_expiration =   '1200';
                    $data=[
                            'LoginId'   =>      $staff->LoginId,
                            'StaffUSI'  =>      $staff->StaffUSI,
                            'RoleId'  =>      $authentication->RoleId,
                            'logged_in' => TRUE,
                        ];
                    if($authentication->RoleId==3 || $authentication->RoleId==4) {
                        $school = $staff->getAssociatedSchool();
                        if ($school != null) {
                            $data['SchoolId'] = $school->EducationOrganizationId;
                            $data['SchoolName'] = $school->NameOfInstitution;
                        }
                    }

                    $this->session->set_userdata($data);<commit_msg>#61 Debugged login failure of new easol users. Users were being authenticated via a missing Loginid value in the edfi.Staff table. I changed login to use the StaffUSI value in edfi.Staff instead.<commit_after><?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Home extends Easol_Controller {


    protected function accessRules(){
        return [
            "index"     =>  "*",
            "logout"    =>  "@",
            "accessdenied"  =>  "@"
        ];
    }
    /**
     * index page
     */
    public function index()
	{
        if($this->session->userdata('logged_in')== true)
        {
            return redirect('/dashboard');
        }

        if(isset($_POST['login']) && $data=$this->input->post('login')) {

            $this->load->model('entities/edfi/Edfi_Staff','Edfi_Staff');
            /* @var $this->Staff Edfi_Staff */
            // = $this->Edfi_Staff->findOne(['LoginId' => $data['username']]);
            // $staff = $this->Edfi_Staff->hydrate($this->Edfi_Staff->findOne(['LoginId' => $data['username']]));
            $staff = $this->Edfi_Staff->hydrate($this->Edfi_Staff->findOne(['StaffUSI' => $data['username']]));
            if($staff) {
                $this->load->model('entities/easol/Easol_StaffAuthentication','easol_authentication');
                $authentication=$this->easol_authentication->findOne(['StaffUSI' => $staff->StaffUSI]);

                if($authentication && $authentication->Password== sha1($data['password'])){
                    $this->session->sess_expiration =   '1200';
                    $data=[
                            'LoginId'   =>      $staff->LoginId,
                            'StaffUSI'  =>      $staff->StaffUSI,
                            'RoleId'  =>      $authentication->RoleId,
                            'logged_in' => TRUE,
                        ];
                    if($authentication->RoleId==3 || $authentication->RoleId==4) {
                        $school = $staff->getAssociatedSchool();
                        if ($school != null) {
                            $data['SchoolId'] = $school->EducationOrganizationId;
                            $data['SchoolName'] = $school->NameOfInstitution;
                        }
                    }

                    $this->session->set_userdata($data);
{'fraction_non_alphanumeric': 0.15908571428571427, 'fraction_numerical': 0.003657142857142857, 'mean_word_length': 1.6731826511912034, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 90, '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': '646080', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1158, 'n_words': 171}