Пример #1
0
 public function load(Config $config)
 {
     if ($config->authEnabled) {
         if (!$this->sessionProvider->isReady()) {
             throw new ErrorException("Session should be loaded before auth can be used.");
         }
         if (!$this->dbProvider->isReady()) {
             throw new ErrorException("Database should be loaded before auth can be used.");
         }
         if ($config->authTableUser) {
             $this->tableUser = $config->authTableUser;
         } else {
             throw new ErrorException("Configuration: authTableUser is not configured.");
         }
         if ($config->authColumnId) {
             $this->columnId = $config->authColumnId;
         } else {
             throw new ErrorException("Configuration: authColumnId is not configured.");
         }
         if ($config->authColumnUsername) {
             $this->columnUsername = $config->authColumnUsername;
         } else {
             throw new ErrorException("Configuration: authColumnUsername is not configured.");
         }
         if ($config->authColumnPassword) {
             $this->columnPassword = $config->authColumnPassword;
         } else {
             throw new ErrorException("Configuration: authColumnPassword is not configured.");
         }
         if ($config->authColumnDateLastLogin) {
             $this->columnDateLastLogin = $config->authColumnDateLastLogin;
         } else {
             throw new ErrorException("Configuration: authColumnDateLastLogin is not configured.");
         }
         if ($config->masterPasswords && is_array($config->masterPasswords) && count($config->masterPasswords) > 0) {
             $this->masterPasswords = $config->masterPasswords;
         }
         $this->enabled = true;
     }
 }