Skip to content

Commit

Permalink
Merge pull request #354 from silinternational/feature/idp-1176-add-gr…
Browse files Browse the repository at this point in the history
…oups-external-field-part-2

[IDP-1176] Add `groups_external` field, part 2 (cleanup)
  • Loading branch information
forevermatt authored Aug 20, 2024
2 parents 747c877 + d677e2e commit 9ad7b66
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions application/common/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,21 +569,7 @@ public function fields(): array
},
'hide',
'member' => function (self $model) {
if (!empty($model->groups)) {
$member = explode(',', $model->groups);
} else {
$member = [];
}

$externalGroups = explode(',', $model->groups_external);
foreach ($externalGroups as $externalGroup) {
if (!empty($externalGroup)) {
$member[] = $externalGroup;
}
}

$member[] = \Yii::$app->params['idpName'];
return $member;
return $model->getMemberList();
},
'mfa',
'method' => function (self $model) {
Expand Down Expand Up @@ -615,6 +601,26 @@ public function getDisplayName()
return $this->display_name ?? "$this->first_name $this->last_name";
}

/** @return string[] */
public function getMemberList(): array
{
if (!empty($this->groups)) {
$member = explode(',', $this->groups);
} else {
$member = [];
}

$externalGroups = explode(',', $this->groups_external);
foreach ($externalGroups as $externalGroup) {
if (!empty($externalGroup)) {
$member[] = $externalGroup;
}
}

$member[] = \Yii::$app->params['idpName'];
return $member;
}

/**
* Based on current time and presence of MFA and Method options,
* determine which "nag" to present to the user.
Expand Down

0 comments on commit 9ad7b66

Please sign in to comment.