Skip to content
Snippets Groups Projects
Commit 32c2d6a4 authored by Kevin Paxman's avatar Kevin Paxman
Browse files

Merge branch 'feature/ISTWCMS-6863-ibiki-ofis_improvements' into '2.0.x'

ISTWCMS-6863: Improving ofis service.

See merge request !9
parents f6440623 a740fe1c
No related branches found
No related tags found
1 merge request!9ISTWCMS-6863: Improving ofis service.
......@@ -35,7 +35,6 @@ class OFISController extends ControllerBase {
* User id.
*/
public function getProfile(string $userid): array {
// Get OFIS config settings in read-only mode.
$ofis_config = $this->configFactory->get('uw_ws_ofis.settings');
......@@ -121,7 +120,7 @@ class OFISController extends ControllerBase {
protected function facultyDisplay(array &$profile): void {
$faculty_title = $profile['personal']['title'];
if (strpos($faculty_title, 'Faculty') !== FALSE) {
if (str_contains($faculty_title, 'Faculty')) {
if ($faculty_title === 'Regular Faculty') {
$faculty_title = $profile['personal']['rank'];
}
......
......@@ -2,8 +2,6 @@
namespace Drupal\uw_ws_ofis\Service;
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
......@@ -131,26 +129,22 @@ class OFISWebService implements OFISWebServiceInterface {
* FALSE otherwise.
*/
protected function validateUserOnSite(string $userid): bool {
$result = FALSE;
try {
$storage = $this->entityTypeManager->getStorage('node');
}
catch (InvalidPluginDefinitionException | PluginNotFoundException $e) {
$storage = FALSE;
// Shortcut if dev is enabled. This will bypass requirement to have
// published contact with same watiam_id.
if ($this->isDev) {
return TRUE;
}
if ($storage) {
$contact = $storage->loadByProperties([
'type' => 'uw_ct_contact',
'field_uw_ct_contact_watiam_id' => $userid,
'status' => NodeInterface::PUBLISHED,
]);
// Using query instead of loadByProperties to bypasss accessCheck.
$query = $this->entityTypeManager->getStorage('node')->getQuery();
$result = (bool) $contact;
}
$contact = $query->accessCheck(FALSE)
->condition('type', 'uw_ct_contact')
->condition('field_uw_ct_contact_watiam_id', $userid)
->condition('status', NodeInterface::PUBLISHED)
->execute();
return $this->isDev || $result;
return (bool) $contact;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment