Beispiel #1
0
 public function login_submit()
 {
     $nomenclator = new \BusinessLogic\Models\NomenclatorModel();
     $pachete = $nomenclator->getPachete(false);
     //userul este deja logat, ii facem redirect la homepage
     if ($this->auth->isLoggedIn()) {
         redirect(base_url());
     }
     //procesam requestul
     $this->form_validation->set_rules('password', 'parola', 'required|xss_clean');
     $this->form_validation->set_rules('email', 'email', 'required');
     $msgRequired = 'Campul <b>%s</b> este obligatoriu';
     if (BusinessLogic\Util\Language::getLanguage() == "en") {
         $msgRequired = 'Please fill in <b>%s</b>.';
     }
     $this->form_validation->set_message('required', $msgRequired);
     if ($this->form_validation->run() == FALSE) {
         $this->session->set_flashdata('notification', array("type" => "error", "html" => BusinessLogic\Util\Language::getLanguage() == "en" ? "Invalid credentials" : "Date incorecte"));
         $this->load_view('user/login', array("no_footer" => true, "no_header" => true, "pachete" => $pachete, "notification" => array("type" => "form_notification", "message" => validation_errors(), "cssClass" => "error")));
     } else {
         $iUserId = $this->auth->authenticateUser($this->input->post('email'), $this->input->post('password'), TRUE);
         if (!$iUserId) {
             $this->session->set_flashdata('notification', array("type" => "error", "html" => "Date Incorecte"));
             //datele introduse nu sunt corecte
             $this->load_view('user/login', array("no_footer" => true, "no_header" => true, "notification" => array("type" => "form_notification", "message" => "Datele introduse sunt incorecte", "cssClass" => "error")));
         } else {
             $this->auth->disconnectAccount($iUserId);
             //Conecteaza utilizatorul curent
             $this->auth->loginUser($iUserId);
             //userul a fost logat
             redirect(base_url('account'));
         }
     }
 }