Commit 8ac5c042 authored by Akhil's avatar Akhil 😶
Browse files

Merge branch 'user-exists-route' into 'nc21'

added user_exists endpoint

See merge request e/infra/selfhost/nextcloud-apps/ecloud-drop-account!5
parents 15f54ca7 cdc092dc
......@@ -2,6 +2,7 @@
return ['routes' => [
['name' => 'user#set_account_data', 'url' => '/api/set_account_data', 'verb' => 'POST'],
['name' => 'user#user_exists', 'url' => '/api/user_exists', 'verb' => 'POST'],
[
'name' => 'user#preflighted_cors', 'url' => '/api/{path}',
'verb' => 'OPTIONS', 'requirements' => array('path' => '.+')
......
......@@ -21,6 +21,23 @@ class UserController extends ApiController
$this->userService = $userService;
}
/**
* @CORS
* @PublicPage
* @NoCSRFRequired
*/
public function userExists(string $token, string $uid): DataResponse
{
$response = new DataResponse();
if (!$this->checkAppCredentials($token)) {
$response->setStatus(401);
return $response;
}
$response->setData($this->userService->userExists($uid));
return $response;
}
/**
* @CORS
* @PublicPage
......@@ -56,7 +73,10 @@ class UserController extends ApiController
return $this->getErrorResponse($response, 'error_setting_recovery', 400);
}
$createdFolder = $this->userService->createUserFolder($uid);
$createdFolder = true;
if ($this->userService->isShardingEnabled()) {
$createdFolder = $this->userService->createUserFolder($uid);
}
if (!$createdFolder) {
$response->setStatus(500);
}
......
......@@ -28,7 +28,7 @@ class UserService
$this->appConfig = $this->config->getSystemValue($appName);
}
private function isShardingEnabled(): bool
public function isShardingEnabled(): bool
{
$shardingEnabled = $this->config->getSystemValue('user_folder_sharding', false);
return $shardingEnabled;
......@@ -65,10 +65,6 @@ class UserService
public function createUserFolder(string $uid): bool
{
// return true as creation can be handled at login if sharding disabled
if (!$this->isShardingEnabled()) {
return true;
}
$realDataDir = $this->getConfigValue('realdatadirectory');
$ncDataDir = $this->config->getSystemValue('datadirectory');
......
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