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

Commit 8d36f5e7 authored by Ronak Patel's avatar Ronak Patel
Browse files

applying suggestion

parent 9215e21a
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ class MapActiveAttributetoLDAP extends Command {
				try {
					$this->userService->mapActiveAttributesInLDAP($username, $isEnabled);
				} catch (Exception $e) {
					$this->logger->error('Failed to update LDAP attributes for user: ' . $username, ['exception' => $e]);
					$this->logger->logException('Failed to update LDAP attributes for user: ' . $username, ['exception' => $e]);
				}
			}
		});
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ class UserChangedListener implements IEventListener {
			try {
				$this->userService->mapActiveAttributesInLDAP($username, $newValue);
			} catch (Exception $e) {
				$this->logger->error('Failed to update LDAP attributes for user: ' . $username, ['exception' => $e]);
				$this->logger->logException('Failed to update LDAP attributes for user: ' . $username, ['exception' => $e]);
			}
		}
	}
+3 −0
Original line number Diff line number Diff line
@@ -520,16 +520,19 @@ class UserService {
			throw new AddUsernameToCommonStoreException("Error adding username '$username' to common data store.");
		}
	}

	public function mapActiveAttributesInLDAP(string $username, bool $isEnabled): void {
		$userActiveAttributes = $this->getActiveAttributes($isEnabled);
		$this->updateAttributesInLDAP($username, $userActiveAttributes);
	}

	private function getActiveAttributes(bool $isEnabled): array {
		return [
			'active' => $isEnabled ? 'TRUE' : 'FALSE',
			'mailActive' => $isEnabled ? 'TRUE' : 'FALSE',
		];
	}

	public function updateAttributesInLDAP(string $username, array $attributes): void {
		if (!$this->LDAPConnectionService->isLDAPEnabled()) {
			return;