/** * @param EventInterface $event * @param null|callable $callback * @throws \Exception */ public function trigger($event, $callback = null) { try { $this->manager->trigger($event, null, null, $callback); } catch (\Exception $ex) { $this->logger->error($ex); throw $ex; } }
/** * Performs an authentication attempt * * @return \Zend\Authentication\Result * @throws \Zend\Authentication\Adapter\Exception\ExceptionInterface If authentication cannot be performed */ public function authenticate() { $login = $this->getLogin(); $password = $this->getPassword(); if (!$login || !$password) { throw new EmptyCredentialsException(); } $data = $this->getUserData($login); if ($data === null) { static::$logger->info("Fail login: user not found '{$login}'"); return new Result(Result::FAILURE_IDENTITY_NOT_FOUND, null); } if ($data->getPassword() === md5($data->getSecret() . $password)) { if ($data->isValid()) { static::$logger->info("Successful authentication for '{$login}'"); return new Result(Result::SUCCESS, $data->getUserId()); } static::$logger->info("Fail authentication for '{$login}'. User is blocked: '" . $data->getStatus() . "'"); return new Result(Result::FAILURE_IDENTITY_AMBIGUOUS, $data->getUserId()); } static::$logger->info("Fail authentication: wrong password for '{$login}'"); return new Result(Result::FAILURE_CREDENTIAL_INVALID, null); }
/** * @param string $currentUserRole */ protected function setCurrentUserRole($currentUserRole) { static::$logger->debug("Role changed '" . $this->currentUserRole . "' > '{$currentUserRole}'"); $this->currentUserRole = $currentUserRole; }