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(); }
public function mvcjs() { $this->load->file('application/modules/app/user_profile/form/profile_form.php'); $this->load->file('application/modules/app/user_profile/form/user_form.php'); $frmProfile = new Form_App_Profile(); $frmUser = new Form_App_User(); $oBus = Business_App_User::loadUser(Helper_App_Session::getUserId()); $data = $oBus->data(); $eUser = $data['eUser']; $frmUser->username = $eUser->username; $params = array('link' => $this->link, 'linkx' => $this->linkx, 'permissions' => $this->permission->toArray(), 'profile_form_default' => $frmProfile->toArray(), 'user_form_default' => $frmUser->toArray()); Helper_App_JS::showMVC('user_profile', $params); }
private function updatePassword() { $this->load->file('application/modules/app/layout/layout_password_data.php'); $resAjax = new Response_Ajax(); $data = new Data_App_Layout_Password(TRUE); try { if (!$data->isValid()) { throw new Exception('Complete correctamente todos los campos'); } $id_user = Helper_App_Session::getUserId(); $oBus = Business_App_User::checkPassword($id_user, $data->password_current); if (!$oBus->isSuccess()) { throw new Exception($oBus->message()); } $data_isValid = $oBus->data(); $isValid = $data_isValid['isValid']; if (!$isValid) { throw new Exception('Contraseña incorrecta.'); } $oBus2 = Business_App_User::updatePassword($id_user, $data->password_new); if (!$oBus2->isSuccess()) { throw new Exception($oBus2->message()); } $data_changed = $oBus2->data(); $changed = $data_changed['changed']; if (!$changed) { throw new Exception("No fue posible cambiar la contraseña"); } $resAjax->isSuccess(TRUE); $resAjax->message("Contraseña cambiada con éxito."); } catch (Exception $ex) { $resAjax->isSuccess(FALSE); $resAjax->message($ex->getMessage()); $resAjax->form('change_password', $data->toArray()); } echo $resAjax->toJsonEncode(); }
private function loadAcount() { $this->load->file('application/modules/app/user_settings/form/user_settings_form.php'); $resAjax = new Response_Ajax(); $id_user = $this->input->post('id_user'); try { //USER $oBusUser = Business_App_User::loadUser($id_user); if (!$oBusUser->isSuccess()) { throw new Exception($oBusUser->message()); } $dataUser = $oBusUser->data(); /* @var $eUser eUser */ $eUser = $dataUser['eUser']; //PERSON $oBusPerson = Business_App_Person::loadByPersonId($eUser->id_person); if (!$oBusPerson->isSuccess()) { throw new Exception($oBusPerson->message()); } $dataPerson = $oBusPerson->data(); /* @var $ePerson ePerson */ $ePerson = $dataPerson['ePerson']; //USER_PROFILE $oBusUserProfile = Business_App_User_Profile::loadUserProfile($eUser->id); if (!$oBusUserProfile->isSuccess()) { throw new Exception($oBusUserProfile->message()); } $dataUserProfile = $oBusUserProfile->data(); /* @var $eUserProfile eUserProfile */ $eUserProfile = $dataUserProfile['eUserProfile']; //COMPANY_BRANCH $oBusCompanyBranch = Business_App_User_Settings::listCompanyBranchsByUserProfile($eUserProfile->id_user, $eUserProfile->id_profile); if (!$oBusCompanyBranch->isSuccess()) { throw new Exception($oBusCompanyBranch->message()); } $dataCompanyBranchs = $oBusCompanyBranch->data(); $eCompanyBranchs = $dataCompanyBranchs['eCompanyBranchs']; $frm_data = new Form_App_User_Settings(); $frm_data->setUserEntity($eUser); $frm_data->setPersonEntity($ePerson); $frm_data->setUserProfileEntity($eUserProfile); $frm_data->setUserProfile_CompanyBranchEntity($eCompanyBranchs); $resAjax->isSuccess(TRUE); } catch (Exception $exc) { $resAjax->isSuccess(FALSE); $resAjax->message($exc->getMessage()); } $resAjax->form('acount', $frm_data->toArray()); echo $resAjax->toJsonEncode(); }
private function changePassword() { $this->load->file('application/forms/app/login_change_password_form.php'); $resAjax = new Response_Ajax(); $oBus = new Response_Business(); $frmChangePassword = new Form_App_Login_Change_Password(TRUE); try { if (!$frmChangePassword->isValid()) { throw new Exception('Complete Correctamente los campo'); } $oBus = Business_App_Token::inactivarUserToken(Helper_Encrypt::decode($frmChangePassword->id_user), 'id_user'); if (!$oBus->isSuccess()) { throw new Exception($oBus->message()); } $oBus = Business_App_User::updatePassword(Helper_Encrypt::decode($frmChangePassword->id_user), $frmChangePassword->new_password); if (!$oBus->isSuccess()) { throw new Exception($oBus->message()); } $resAjax->isSuccess(TRUE); $resAjax->message($oBus->message()); } catch (Exception $ex) { $resAjax->isSuccess(FALSE); $resAjax->message($ex->getMessage()); $resAjax->form('changePassword', $frmChangePassword->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(); }