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

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

Remove filesystem service file

parent 74ce175a
Loading
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ use OCA\EcloudAccounts\Exception\AddUsernameToCommonStoreException;
use OCA\EcloudAccounts\Exception\LDAPUserCreationException;
use OCA\EcloudAccounts\Exception\RecoveryEmailValidationException;
use OCA\EcloudAccounts\Service\CaptchaService;
use OCA\EcloudAccounts\Service\FilesystemService;
use OCA\EcloudAccounts\Service\HCaptchaService;
use OCA\EcloudAccounts\Service\NewsLetterService;
use OCA\EcloudAccounts\Service\UserService;
@@ -46,7 +45,6 @@ class AccountController extends Controller {
	private IConfig $config;
	private IInitialState $initialState;
	private IAppData $appData;
	private FilesystemService $fsService;
	private const SESSION_VERIFIED_USERNAME = 'verified_username';
	private const SESSION_VERIFIED_DISPLAYNAME = 'verified_displayname';
	private const CAPTCHA_VERIFIED_CHECK = 'captcha_verified';
@@ -72,7 +70,6 @@ class AccountController extends Controller {
		ILogger $logger,
		IInitialState $initialState,
		IAppData $appData,
		FilesystemService $fsService
	) {
		parent::__construct($AppName, $request);
		$this->appName = $AppName;
@@ -89,7 +86,6 @@ class AccountController extends Controller {
		$this->request = $request;
		$this->initialState = $initialState;
		$this->appData = $appData;
		$this->fsService = $fsService;
	}

	/**

lib/Service/FilesystemService.php

deleted100644 → 0
+0 −61
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace OCA\EcloudAccounts\Service;

use OCP\IConfig;
use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IUserManager;

class FilesystemService {
	/** @var IUserManager */
	private $userManager;
	/** @var IConfig */
	private $config;
	/** @var ILogger */
	private $logger;
	/** @var IGroupManager */
	private $groupManager;

	public function __construct(IUserManager $userManager, IConfig $config, ILogger $logger, IGroupManager $groupManager) {
		$this->userManager = $userManager;
		$this->config = $config;
		$this->logger = $logger;
		$this->groupManager = $groupManager;
	}

	public function addUserInFilesEnabledGroup($username): bool {
		$user = $this->userManager->get($username);
		if (!$user) {
			return false;
		}

		$groupName = $this->config->getSystemValue('files_access_group_name', '');
		if (!$this->groupManager->groupExists($groupName)) {
			$this->logger->error("$groupName group not exist.");
			return false;
		}

		$group = $this->groupManager->get($groupName);
		$group->addUser($user);
		return true;
	}

	public function checkFilesGroupAccess($username): bool {
		$groupName = $this->config->getSystemValue('files_access_group_name', '');
		
		if (!$this->groupManager->groupExists($groupName)) {
			$this->logger->error("$groupName group not exist.");
			return false;
		}

		if ($this->groupManager->isInGroup($username, $groupName)) {
			return true;
		}

		return false;
	}

}