public function getUser() { if ($this->user != null) { return $this->user; } // for test $this->user = new GuestUser(); try { if (isset($_COOKIE["ut"])) { if (isset($_COOKIE["uh"]) && isset($_COOKIE["ud"])) { if ($_COOKIE["ut"] == UserGroups::$CARWASH) { $user = new CarwashUser($_COOKIE["ud"]); } else { if ($_COOKIE["ut"] == UserGroups::$ADMIN) { $user = new AdminUser($_COOKIE["ud"]); } } } } if (isset($user) && $user->validate($_COOKIE["uh"])) { $this->user = $user; } if ($this->user && $this->user->getLevel() != UserGroups::$GUEST) { $hash = $_COOKIE["uh"]; $this->user->setUniqueId($hash, false); } } catch (InvalidUserException $ex) { } return $this->user; }
/** * @deprecated * register user for admin * DO NOT USE this method is not working */ public function actionRegister() { $user = new AdminUser(); if ($user->validate()) { /** * generate user password */ /** * @todo: not good method for save password need REFACTORING */ // $pass = Security::createPassword($user); // $password = Security::cryptPassword($pass,Config::get('auth.salt')); // $user->password = $password; $pass = $user->password; $user->password = Security::cryptPassword($user->password, Config::get('auth.salt')); $user->save(false); } }