Skip to content

Commit

Permalink
Make splitting keys on '.' optional
Browse files Browse the repository at this point in the history
  • Loading branch information
lost1227 committed Mar 11, 2024
1 parent a52f498 commit 74a08ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Template/config/integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<?= $this->form->label(t('User ID Key'), 'oauth2_key_user_id') ?>
<?= $this->form->text('oauth2_key_user_id', $values) ?>

<?= $this->form->hidden('oauth2_split_keys', array('oauth2_split_keys' => 0)) ?>
<?= $this->form->checkbox('oauth2_split_keys', t('Use composite keys?'), 1, isset($values['oauth2_split_keys']) && $values['oauth2_split_keys'] == 1) ?>
<p class="form-help"><?= t('Interpret \'.\' in keys as keys for sub-objects') ?></p>

<?= $this->form->hidden('oauth2_account_creation', array('oauth2_account_creation' => 0)) ?>
<?= $this->form->checkbox('oauth2_account_creation', t('Allow Account Creation'), 1, isset($values['oauth2_account_creation']) && $values['oauth2_account_creation'] == 1) ?>

Expand Down
20 changes: 15 additions & 5 deletions User/GenericOAuth2UserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,21 @@ public function validateDomainRestriction(array $profile, $domains)

protected function getKey($key)
{
$key = explode('.', $this->configModel->get($key));
$value = $this->userData;
foreach ($key as $k) {
$value = $value[$k];
if($this->configModel->get('oauth2_split_keys') == 1) {
$key = explode('.', $this->configModel->get($key));
$value = $this->userData;
foreach ($key as $k) {
$value = $value[$k];
}
return ! empty($key) && isset($value) ? $value : '';
} else {
$key = $this->configModel->get($key);
if(empty($key)) {
return '';
}

$value = $this->userData[$key];
return isset($value) ? $value : '';
}
return ! empty($key) && isset($value) ? $value : '';
}
}

0 comments on commit 74a08ae

Please sign in to comment.