public function prepareUser($data) { $protect = new \Library\BL\Core\Encryption(); $user = new \Applications\PMTool\Models\Dao\User(); $user->setUser_login($data["username"]); if (!isset($data["encrypt_pwd"])) { $user->setUser_password($data["pwd"]); } else { $user->setUser_password($protect->Encrypt($this->encryptionKey, $data["pwd"])); } //Search for user in DB and return him $user_db = $this->loginManager->selectOne($user); if (count($user_db) === 1) { $this->user = $user_db[0]; //Search for user in DB and return him $user_type = $this->loginManager->selectUserType($this->user); if (count($user_type) === 1) { $this->userType = $user_type[0]; } } }
public static function AddUser($caller, $user_value, $user_role_id, $user_type = NULL) { if ($user_type === NULL) { $user_type = self::GetTypeFromRoleId($user_role_id); } $dataPost = $caller->dataPost(); $userEmail = self::GetEMailForUser($caller, $dataPost, $user_type, $user_value); $manager = $caller->managers()->getManagerOf('User'); $generatedDataPost = array('user_login' => $userEmail, 'user_password' => $userEmail, 'user_email' => $userEmail, 'user_hint' => '', 'user_role_id' => $user_role_id, 'user_type' => $user_type, 'user_value' => $user_value); $user = CommonHelper::PrepareUserObject($generatedDataPost, new \Applications\PMTool\Models\Dao\User()); $protect = new \Library\BL\Core\Encryption(); $user->setUser_password($protect->Encrypt($caller->app()->config()->get("encryption_key"), $user->user_password())); return $manager->add($user); }
/** * Method that logout a user from the session and then redirect him to Login page. * * @param \Library\HttpRequest $rq */ public function executeCreate(\Library\HttpRequest $rq) { $protect = new \Library\BL\Core\Encryption(); $data = array("user_login" => $rq->getData("login"), "user_password" => $rq->getData("password"), "user_type" => $rq->getData("type"), "user_role" => \Applications\PMTool\Helpers\UserHelper::GetRoleFromType($rq->getData("type"))); $user = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($data, new Applications\PMTool\Models\Dao\User()); $user->setUser_password($protect->Encrypt($this->app->config->get("encryption_key"), $user->user_password())); $loginDal = $this->managers->getManagerOf("Login"); $id = $loginDal->add($pm); $redirect = intval($id) > 0 ? TRUE : FALSE; if ($redirect) { $this->Redirect("login"); } }
public function executeEditTechnician(\Library\HttpRequest $rq) { // Init result $result = $this->InitResponseWS(); $dataPost = $this->dataPost(); $technicianId = $dataPost['technician_id']; $result_user = false; //Init PDO $manager = $this->managers->getManagerOf('User'); $technician = $manager->selectUserByTypeId('technician_id', $technicianId); $technician->setUser_hint($dataPost['user_hint']); if ($dataPost['user_password'] != "") { $protect = new \Library\BL\Core\Encryption(); $technician->setUser_password($protect->Encrypt($this->app->config->get("encryption_key"), $dataPost['user_password'])); } $manager = $this->managers->getManagerOf($this->module); $result['user'] = $result_user = $manager->edit($technician, "user_id"); $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::User, "resx_key" => $this->action(), "step" => $result_user ? "success" : "error")); }