Improve logic for determining org connection status

Created on 21 July 2023, 11 months ago
Updated 25 July 2023, 11 months ago

Problem/Motivation

There is logic to determine if the JD Organization has granted access to the farmOS/JD Client application. This logic checks to see if the "connections" or "manage_connection" link is provided.

The current logic is simple and assumes that "connections" will always be the 2nd array entry, "manage_connection" the 3rd array entry. This logic consistently produces the following warning when an organization does not have the "connections" link:

Warning: Undefined array key 2 in Drupal\farm_jd\Controller\AuthController->status() (line 129 of modules/farm_jd/src/Controller/AuthController.php).
Drupal\farm_jd\Controller\AuthController->status()

Steps to reproduce

Connect to JD with an organization that does not have access, check logs.

Proposed resolution

Instead of assuming array indices will exist, use a loop over the organization links to check for "connections" and "manage_connection" links.

Also this logic is using the JDClientInterface::getOrganizations function. This function only returns the organization links. This function should be updated to return all of the organization data, not only the links.

Remaining tasks

Make above changes.

User interface changes

None.

API changes

Modify JDClientInterface::getOrganizations

Data model changes

None.

๐Ÿ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States paul121 Spokane, WA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024