Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
fix(agent): find FI agent by name on enrolment
Browse files Browse the repository at this point in the history
Signed-off-by: Domingo Oropeza <doropeza@teclib.com>
  • Loading branch information
DIOHz0r committed Jul 17, 2018
1 parent 8bf4a41 commit 727a8ae
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions inc/agent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ public function prepareInputForAdd($input) {
}

// User already logged in : user token has been validated

ini_set("memory_limit", "-1");
ini_set("max_execution_time", "0");
switch ($this->chooseEnrollMethod($input)) {
case self::ENROLL_DENY:
$this->filterMessages(Session::addMessageAfterRedirect(__('Unable to find a enrollment method', 'flyvemdm')));
Expand Down Expand Up @@ -1259,7 +1260,6 @@ protected function enrollByInvitationToken($input) {

// Create the device
$pfCommunication = new PluginFusioninventoryCommunication();
$pfAgent = new PluginFusioninventoryAgent();
$_SESSION['glpi_fusionionventory_nolock'] = true;
ob_start();
if (!key_exists('glpi_plugin_fusioninventory', $_SESSION) || !key_exists('xmltags',
Expand All @@ -1278,14 +1278,15 @@ protected function enrollByInvitationToken($input) {
unset($_SESSION['glpi_fusionionventory_nolock']);
$fiAgentId = $_SESSION['plugin_fusioninventory_agents_id']; // generated by FusionInventory

if ($fiAgentId === 0) {
if ($fiAgentId === 0 || !property_exists($parsedXml, 'DEVICEID')) {
$event = __('Cannot get the FusionInventory agent', 'flyvemdm');
$this->filterMessages($event);
$this->logInvitationEvent($invitation, $event);
return false;
}

if (!$pfAgent->getFromDB($fiAgentId)) {
$pfAgent = new PluginFusioninventoryAgent();
if (!$pfAgent->getFromDBByCrit(['device_id' => $parsedXml->DEVICEID])) {
$event = __('FusionInventory agent not created', 'flyvemdm');
$this->filterMessages($event);
$this->logInvitationEvent($invitation, $event);
Expand Down

0 comments on commit 727a8ae

Please sign in to comment.