Skip to content

Commit

Permalink
Merge pull request #278 from silinternational/idp-1043
Browse files Browse the repository at this point in the history
Release 10.0.2 -- assign all values nag controller needs
  • Loading branch information
briskt authored Sep 17, 2024
2 parents 15fe0bf + 30710c2 commit bb978d0
Showing 1 changed file with 30 additions and 25 deletions.
55 changes: 30 additions & 25 deletions modules/profilereview/src/Auth/Process/ProfileReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public function process(array &$state): void
$isHeadedToProfileUrl = self::isHeadedToProfileUrl($state, $this->profileUrl);

$mfa = $this->getAttributeAllValues('mfa', $state);
$method = $this->getAttributeAllValues('method', $state);
$method = $this->getMethod($state);
$profileReview = $this->getAttribute('profile_review', $state);

if (!$isHeadedToProfileUrl) {
Expand All @@ -240,7 +240,7 @@ public function process(array &$state): void
}

if (self::needToShow($profileReview, self::REVIEW_PAGE)) {
$this->redirectToProfileReview($state, $employeeId, $mfa['options'], $method['options']);
$this->redirectToProfileReview($state, $employeeId);
}
}

Expand All @@ -264,48 +264,37 @@ public function process(array &$state): void
*
* @param array $state The state data.
* @param string $employeeId The Employee ID of the user account.
* @param array $mfaOptions A list of the mfa options.
* @param array $methodOptions A list of the method options.
*/
protected function redirectToProfileReview(&$state, $employeeId, $mfaOptions, $methodOptions)
protected function redirectToProfileReview(array &$state, string $employeeId): void
{
assert('is_array($state)');

foreach ($mfaOptions as $key => $mfaOption) {
if ($mfaOption['type'] === 'manager') {
unset ($mfaOptions[$key]);
}
}
$mfaOptions = $this->getAllMfaOptionsExceptManager($state);
$methodOptions = $this->getMethod($state)['options'];

if (count($mfaOptions) == 0 && count($methodOptions) == 0) {
return;
}

/* Save state and redirect. */
$state['employeeId'] = $employeeId;
$state['profileUrl'] = $this->profileUrl;
$state['mfaOptions'] = $mfaOptions;
$state['methodOptions'] = $methodOptions;
$state['template'] = 'review';

$stateId = State::saveState($state, self::STAGE_SENT_TO_NAG);
$url = Module::getModuleURL('profilereview/nag.php');

$httpUtils = new HTTP();
$httpUtils->redirectTrustedURL($url, array('StateId' => $stateId));
$this->redirectToNag($state, $employeeId, 'review');
}

/**
* Redirect user to a template
*
* @param array $state
* @param string $employeeId
* @param string $template
*/
protected function redirectToNag(&$state, $employeeId, $template)
protected function redirectToNag(array &$state, string $employeeId, string $template): void
{
$mfaOptions = $this->getAllMfaOptionsExceptManager($state);
$methodOptions = $this->getMethod($state)['options'];

/* Save state and redirect. */
$state['employeeId'] = $employeeId;
$state['mfaLearnMoreUrl'] = $this->mfaLearnMoreUrl;
$state['profileUrl'] = $this->profileUrl;
$state['mfaOptions'] = $mfaOptions;
$state['methodOptions'] = $methodOptions;
$state['template'] = $template;

$stateId = State::saveState($state, self::STAGE_SENT_TO_NAG);
Expand All @@ -315,6 +304,22 @@ protected function redirectToNag(&$state, $employeeId, $template)
$httpUtils->redirectTrustedURL($url, array('StateId' => $stateId));
}

public function getMethod(array $state): ?array
{
return $this->getAttributeAllValues('method', $state);
}

protected function getAllMfaOptionsExceptManager(array $state): array
{
$mfaOptions = $this->getAttributeAllValues('mfa', $state)['options'];
foreach ($mfaOptions as $key => $mfaOption) {
if ($mfaOption['type'] === 'manager') {
unset ($mfaOptions[$key]);
}
}
return $mfaOptions;
}

public static function hasSeenSplashPageRecently(string $page)
{
$session = Session::getSessionFromRequest();
Expand Down

0 comments on commit bb978d0

Please sign in to comment.