Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve typing in apps/user_ldap/lib/Command/CheckUser.php
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Mar 10, 2022
commit 07458e62bd4f6d5e4057a19549e1ea3e77a4d4b8
16 changes: 4 additions & 12 deletions apps/user_ldap/lib/Command/CheckUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*
* @author Arthur Schiwon <[email protected]>
* @author Christoph Wurst <[email protected]>
* @author Côme Chilliet <[email protected]>
* @author Joas Schilling <[email protected]>
* @author Morris Jobke <[email protected]>
* @author Roeland Jago Douma <[email protected]>
Expand Down Expand Up @@ -48,12 +49,6 @@ class CheckUser extends Command {
/** @var UserMapping */
protected $mapping;

/**
* @param User_Proxy $uBackend
* @param Helper $helper
* @param DeletedUsersIndex $dui
* @param UserMapping $mapping
*/
public function __construct(User_Proxy $uBackend, Helper $helper, DeletedUsersIndex $dui, UserMapping $mapping) {
$this->backend = $uBackend;
$this->helper = $helper;
Expand All @@ -62,7 +57,7 @@ public function __construct(User_Proxy $uBackend, Helper $helper, DeletedUsersIn
parent::__construct();
}

protected function configure() {
protected function configure(): void {
$this
->setName('ldap:check-user')
->setDescription('checks whether a user exists on LDAP.')
Expand All @@ -89,7 +84,7 @@ protected function configure() {
protected function execute(InputInterface $input, OutputInterface $output): int {
try {
$uid = $input->getArgument('ocName');
$this->isAllowed($input->getOption('force'));
$this->assertAllowed($input->getOption('force'));
$wasMapped = $this->userWasMapped($uid);
$exists = $this->backend->userExistsOnLDAP($uid, true);
if ($exists === true) {
Expand Down Expand Up @@ -125,9 +120,8 @@ protected function userWasMapped(string $ocName): bool {
/**
* checks whether the setup allows reliable checking of LDAP user existence
* @throws \Exception
* @return true
*/
protected function isAllowed($force) {
protected function assertAllowed(bool $force): void {
if ($this->helper->haveDisabledConfigurations() && !$force) {
throw new \Exception('Cannot check user existence, because '
. 'disabled LDAP configurations are present.');
Expand All @@ -136,8 +130,6 @@ protected function isAllowed($force) {
// we don't check ldapUserCleanupInterval from config.php because this
// action is triggered manually, while the setting only controls the
// background job.

return true;
}

private function updateUser(string $uid, OutputInterface $output): void {
Expand Down