コード例 #1
0
ファイル: Action.php プロジェクト: anddorua/biblio
 private function parseAction($action)
 {
     if (!isset($action['class'])) {
         throw new \Exception('Class not defined. Use \'class\' field to define class name containing invocable method.');
     }
     $className = '\\Invocable\\' . $action['class'];
     if (!class_exists($className)) {
         throw new \Exception('Class \'' . $className . '\' not exists.');
     }
     $this->classInstance = new $className();
     if (!$this->classInstance instanceof \Invocable\Base) {
         throw new \Exception('Class \'' . $className . '\' not instance of \\Invocable\\Base.');
     }
     if (!isset($action['method'])) {
         throw new \Exception('Method name not defined. Use \'method\' field to define class method to invoke.');
     }
     $this->methodName = $action['method'];
     $auth = new \Utility\Authorization();
     if (!$auth->isAuthorized() && false === array_search($this->methodName, $this->unauthorized_methods)) {
         throw new \Utility\EUnauthorized("Необходима авторизация.");
     }
     if (!method_exists($this->classInstance, $this->methodName)) {
         throw new \Exception('Method \'' . $this->methodName . '\' not implemented.');
     }
     $this->params = isset($action['params']) ? is_array($action['params']) ? $action['params'] : array($action['params']) : array();
     //error_log(print_r($action, true), 3, 'my_errors.txt');
 }
コード例 #2
0
ファイル: DataSource.php プロジェクト: anddorua/biblio
 public function auth($params)
 {
     $result = new \stdClass();
     $result->login = $params['login'];
     $result->isAuthenticated = false;
     $result->isAdmin = false;
     $result->requireChangePassword = true;
     $operMapper = new \DBMappers\OperItem();
     sleep(1);
     if ($operItem = $operMapper->getByLogin($result->login)) {
         if ($operItem->isPasswordEqual($params['password'])) {
             $result->firstname = $operItem->getFirstname();
             $result->lastname = $operItem->getLastname();
             $result->isAuthenticated = true;
             $result->isAdmin = $operItem->isAdmin();
             $result->requireChangePassword = is_null($operItem->getPwdHash());
             $auth = new \Utility\Authorization();
             $auth->setAuthorized($operItem->getLogin(), $operItem->isAdmin());
         }
     }
     return $result;
 }