Skip to content

Meaningful_redirect_when_no_valid_identifier #25

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,18 @@ public function isAuthorized(): array|bool
$cfg = $this->CoGrouperLiteWidget->getConfig();
// Find the identifier
$copersonid = !empty($roles['copersonid']) ? $roles['copersonid'] : $pids['copersonid'];
$this->setUserId($this->GrouperGroup->getIdentifierFromPersonId($copersonid,
$cfg['CoGrouperLiteWidget']['identifier_type']));

$identifier = $this->GrouperGroup->getIdentifierFromPersonId($copersonid,
$cfg['CoGrouperLiteWidget']['identifier_type']);
if(empty($identifier)) {
// Redirect to the dashboard
$this->Flash->set(
_txt('er.grouperlite.ident.notfound', array($cfg['CoGrouperLiteWidget']['identifier_type'])),
array('key' => 'error')
);
$this->performRedirect();
}
$this->setUserId($identifier);

// Find if the user belongs to Group
$eligibleGroup = $cfg['CoGrouperLiteWidget']['act_as_grp_name'];
Expand Down Expand Up @@ -633,6 +643,24 @@ public function parseCOID($data = null): int {
return -1;
}

/**
* Perform a redirect back to the controller's default view.
* - postcondition: Redirect generated
*
* @since COmanage Registry v4.4.0
*/

public function performRedirect() {
// Redirect back to the default index sort

$this->redirect(array(
'controller' => 'co_dashboards',
'plugin' => null,
'action' => 'dashboard',
'co' => $this->cur_co['Co']['id']
));
}

/**
* Remove a member from a group
*
Expand Down Expand Up @@ -675,7 +703,7 @@ public function removeSubscriber(): void
* @param $statusTxt $contentType Status text
*
* @throws JsonException
* @since COmanage Registry v4.4.4
* @since COmanage Registry v4.4.0
*/

public function restResponse(int $status,
Expand Down
3 changes: 2 additions & 1 deletion Lib/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,6 @@
'pl.grouperlite.members.noaccess' => 'You do not have access to view memberships.',
'pl.grouperlite.members.empty' => 'This group has no member OR you are not authorized to see the members of this group.',

'er.grouperlite.glid' => 'Named parameter glid was not found',
'er.grouperlite.glid' => 'Named parameter glid was not found',
'er.grouperlite.ident.notfound' => '"%1$s" Identifier not found.',
];