/**
  * Validate storage config
  *
  * @param StorageConfig $storage storage config
  *
  * @return DataResponse|null returns response in case of validation error
  */
 protected function validate(StorageConfig $storage)
 {
     $result = parent::validate($storage);
     if ($result != null) {
         return $result;
     }
     // Verify that the mount point applies for the current user
     // Prevent non-admin users from mounting local storage and other disabled backends
     $allowedBackends = \OC_Mount_Config::getPersonalBackends();
     if (!isset($allowedBackends[$storage->getBackendClass()])) {
         return new DataResponse(array('message' => (string) $this->l10n->t('Invalid storage backend "%s"', array($storage->getBackendClass()))), Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     return null;
 }
示例#2
0
 /**
  * Validate storage config
  *
  * @param StorageConfig $storage storage config
  *
  * @return DataResponse|null returns response in case of validation error
  */
 protected function validate(StorageConfig $storage)
 {
     $result = parent::validate($storage);
     if ($result !== null) {
         return $result;
     }
     // Verify that the mount point applies for the current user
     // Prevent non-admin users from mounting local storage and other disabled backends
     /** @var Backend */
     $backend = $storage->getBackend();
     if (!$backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) {
         return new DataResponse(array('message' => (string) $this->l10n->t('Admin-only storage backend "%s"', [$storage->getBackend()->getIdentifier()])), Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     return null;
 }