Skip to content

Fully impersonate a user #19

Merged
merged 1 commit into from
Apr 5, 2024
Merged
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
22 changes: 13 additions & 9 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,18 @@ public function beforeRender() {
$this->getActAsIdentifier(),
$cfg)
);
// $this->set('vv_is_template_user', $this->GrouperGroup->isTemplateUser($this->userId ?? '', $cfg) );
// $this->set('vv_is_grouper_visible', $this->GrouperGroup->isGrouperVisible($this->userId ?? '', $cfg));
// $this->set('vv_is_template_user', $this->GrouperGroup->isTemplateUser($this->getUserId(), $cfg) );
// $this->set('vv_is_grouper_visible', $this->GrouperGroup->isGrouperVisible($this->getUserId(), $cfg));
}

/**
* @return null|string
*/
public function getActAsIdentifier(): ?string
{
//If the actor Identifier is not set we will return the current user
// XXX We are anot acting as but we are impersonating an other user. As a result
// both the actor and the user need to have the same identifier
// If the actor Identifier is not set we will return the current user
return $this->actAsIdentifier ?? $this->getUserId();
}

Expand Down Expand Up @@ -248,9 +250,11 @@ public function findSubscriber(): void
/**
* @return null|string
*/
public function getUserId(): null|string
public function getUserId(): ?string
{
return $this->userId;
// XXX We are anot acting as but we are impersonating an other user. As a result
// both the actor and the user need to have the same identifier
return $this->actAsIdentifier ?? $this->userId;
}

/**
Expand Down Expand Up @@ -317,7 +321,7 @@ public function groupSubscribers(): void
public function groupOwnerApi(): void {
//Set initial setting
$arguments = [
'userId' => $this->userId,
'userId' => $this->getUserId(),
'actorUserId' => $this->getActAsIdentifier(),
'cfg' => $this->CoGrouperLiteWidget->getConfig()
];
Expand Down Expand Up @@ -359,7 +363,7 @@ public function groupOwnerApi(): void {
public function groupMemberApi(): void {
//Set initial setting
$arguments = [
'userId' => $this->userId,
'userId' => $this->getUserId(),
'actorUserId' => $this->getActAsIdentifier(),
'cfg' => $this->CoGrouperLiteWidget->getConfig()
];
Expand Down Expand Up @@ -404,7 +408,7 @@ public function groupMemberApi(): void {
public function groupOptinApi() {
//Set initial setting
$arguments = [
'userId' => $this->userId,
'userId' => $this->getUserId(),
'actorUserId' => $this->getActAsIdentifier(),
'cfg' => $this->CoGrouperLiteWidget->getConfig()
];
Expand Down Expand Up @@ -582,7 +586,7 @@ public function leaveGroup(): void
try {
if(!$this->GrouperGroup->removeGroupMember($this->getActAsIdentifier(),
$groupName,
$this->userId,
$this->getUserId(),
$this->CoGrouperLiteWidget->getConfig())) {
// The Request returned unsuccessful, but we have not more infomration. In this case we will just return
// forbidden since we do not actually now what happened
Expand Down