Commit 829f6b79 authored by Akhil's avatar Akhil 😶
Browse files

Removed Istorage

parent 3f9d1358
......@@ -2,4 +2,8 @@
return ['routes' => [
['name' => 'user#set_account_data', 'url' => '/api/set_account_data', 'verb' => 'POST'],
[
'name' => 'user#preflighted_cors', 'url' => '/api/{path}',
'verb' => 'OPTIONS', 'requirements' => array('path' => '.+')
],
]];
......@@ -29,9 +29,11 @@ namespace OCA\EcloudAccounts\AppInfo;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\User\Events\UserDeletedEvent;
use OCA\EcloudAccounts\Events\UserDeletedListener;
class Application extends App
{
......@@ -46,4 +48,8 @@ class Application extends App
{
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
}
public function boot(IBootContext $context) {
}
}
......@@ -56,7 +56,7 @@ class UserController extends ApiController
}
private function checkAppCredentials(string $token) : bool {
$ecloud_accounts_secret = $_ENV['ECLOUD_ACCOUNTS_SECRET'];
$ecloud_accounts_secret = $this->userService->getConfigValue('secret');
return strcmp($token, $ecloud_accounts_secret) === 0;
}
}
......@@ -6,7 +6,6 @@ namespace OCA\EcloudAccounts\Service;
use OCP\IUserManager;
use OCP\IConfig;
use OCP\Files\Storage\IStorage;
class UserService
{
......@@ -20,24 +19,11 @@ class UserService
/** @var IConfig */
private $config;
private $appName;
private $storage;
public function __construct($appName, IUserManager $userManager, IConfig $config, IStorage $storage)
public function __construct( $appName, IUserManager $userManager, IConfig $config)
{
$this->userManager = $userManager;
$this->config = $config;
$this->appConfig = $this->config->getSystemValue($appName);
$this->appName = $appName;
$this->storage = $storage;
}
private function getConfigValue(string $key) {
if(array_key_exists($key, $this->appConfig)) {
return $this->appConfig[$key];
}
return false;
}
private function isShardingEnabled(): bool
......@@ -46,6 +32,14 @@ class UserService
return $shardingEnabled;
}
public function getConfigValue(string $key) {
if(!empty($this->appConfig[$key])) {
return $this->appConfig[$key];
}
return false;
}
public function userExists(string $uid): bool
{
return $this->userManager->userExists($uid);
......@@ -82,19 +76,19 @@ class UserService
return false;
}
// Folder already exists
if (file_exists($ncUserFolder)) {
return true;
}
// Randomly assign a directory for the new user
$directories = glob($realDataDir . '/*', GLOB_ONLYDIR);
$folderIndex = random_int(0, count($directories) - 1);
$folder = $directories[$folderIndex];
$realUserFolder = $folder . '/' . $uid;
// Folder already exists
if ($this->storage->file_exists($realUserFolder)) {
return true;
}
try {
$created = $this->storage->mkdir($realUserFolder);
$created = mkdir($realUserFolder);
if (!$created) {
$this->logger->error('Error while creating user folder for user: ' . $uid);
return false;
......@@ -109,5 +103,6 @@ class UserService
$this->logger->error("Error while creating user folder and linking for user: " . $uid);
return false;
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment