private function check()
 {
     $this->load->file('application/modules/app/login/login_data.php');
     $resAjax = new Response_Ajax();
     $dataLogin = new Data_App_Login(TRUE);
     $dataLoginError = NULL;
     //Helper_Log::write($_SESSION);
     try {
         $id_company = Helper_Config::getCompanyId();
         if (!$dataLogin->isValid($dataLoginError, FALSE)) {
             throw new Exception('Complete correctamente todos los campos 001');
         }
         $oBus = Business_App_User::login($dataLogin->username, $dataLogin->password);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $data = $oBus->data();
         /* @var $eUser eUser */
         $eUser = $data['eUser'];
         Helper_App_Session::init($id_company, $eUser->id);
         $resAjax->isSuccess(TRUE);
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
         $resAjax->data('login_error', $dataLoginError->toArray());
     }
     echo $resAjax->toJsonEncode();
 }
Example #2
0
 private function check()
 {
     $this->load->file('application/modules/app/login/login_data.php');
     $resAjax = new Response_Ajax();
     $dataLogin = new Data_App_Login(TRUE);
     $dataLoginError = NULL;
     //Helper_Log::write($_SESSION);
     try {
         $id_company = Helper_Config::getCompanyId();
         if (!$dataLogin->isValid($dataLoginError)) {
             throw new Exception('Complete correctamente todos los campos 001');
         }
         if (ENVIRONMENT != 'development') {
             if (!Helper_Captcha::isValid($this->name_key, $dataLogin->security)) {
                 throw new Exception('Código de seguridad inválido.');
                 //throw new Exception('Complete correctamente todos los campos 002');
             }
         }
         $oBus = Business_App_User::login($dataLogin->username, $dataLogin->password);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $data = $oBus->data();
         /* @var $eUser eUser */
         $eUser = $data['eUser'];
         Helper_App_Session::init($id_company, $eUser->id);
         //Helper_App_Session::buildData();
         /*$eSessionActivity = new eSessionActivity();
           $eSessionActivity->id_user = Helper_App_Session::getUserId();
           $eSessionActivity->inUse = 1;
           $eSessionActivity->last_activity = date('Y-m-d H:i:s');
           $eSessionActivity->session_id = Helper_App_Session::getSessionID();
           */
         //Helper_App_Activity::set($eSessionActivity);
         $resAjax->isSuccess(TRUE);
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
         $resAjax->data('login_error', $dataLoginError->toArray());
     }
     echo $resAjax->toJsonEncode();
 }
 private function saveUser()
 {
     $this->load->file('application/modules/app/user_profile/form/user_form.php');
     $resAjax = new Response_Ajax();
     $frm_data = new Form_App_User(TRUE);
     try {
         if (!$this->permission->update) {
             throw new Exception('No tiene permisos para editar/actualizar');
         }
         if (!$frm_data->isValid()) {
             throw new Exception('Debe ingresar la información en todos los campos');
         }
         $oBus = Business_App_User::loadUser(Helper_App_Session::getUserId());
         $data = $oBus->data();
         $eUser = $data['eUser'];
         $oBus = Business_App_User::login($eUser->username, $frm_data->password_current);
         if (!$oBus->isSuccess()) {
             throw new Exception('Contraseña Incorrecta');
         }
         $oBus = Business_App_User::updatePassword($eUser->id, $frm_data->password_new_repeat);
         $resAjax->isSuccess(TRUE);
         $resAjax->message('Contraseña Actualizada');
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
         $resAjax->form('user', $frm_data->toArray());
     }
     echo $resAjax->toJsonEncode();
 }