Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cdc092dc authored by Akhil's avatar Akhil 🙂
Browse files

added user_exists endpoint

parent 15f54ca7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 −1
Original line number Diff line number Diff line
@@ -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 = true;
        if ($this->userService->isShardingEnabled()) {
            $createdFolder = $this->userService->createUserFolder($uid);
        }
        if (!$createdFolder) {
            $response->setStatus(500);
        }
+1 −5
Original line number Diff line number Diff line
@@ -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');