Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emulate entity on Admin OCS API #1214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 16 additions & 6 deletions lib/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

namespace OCA\Circles\Controller;

use OCA\Circles\Tools\Traits\TDeserialize;
use OCA\Circles\Tools\Traits\TNCLogger;
use Exception;
use OCA\Circles\Exceptions\ContactAddressBookNotFoundException;
use OCA\Circles\Exceptions\ContactFormatException;
Expand All @@ -52,6 +50,8 @@
use OCA\Circles\Service\MemberService;
use OCA\Circles\Service\MembershipService;
use OCA\Circles\Service\SearchService;
use OCA\Circles\Tools\Traits\TDeserialize;
use OCA\Circles\Tools\Traits\TNCLogger;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCSController;
Expand Down Expand Up @@ -263,6 +263,7 @@ public function memberLevel(string $emulated, string $circleId, string $memberId
* @param string $emulated
* @param int $limit
* @param int $offset
*
* @return DataResponse
* @throws OCSException
*/
Expand Down Expand Up @@ -482,9 +483,6 @@ public function editSetting(string $emulated, string $circleId, string $setting,
}





/**
* @param string $emulated
* @param string $circleId
Expand Down Expand Up @@ -529,7 +527,7 @@ public function link(string $emulated, string $circleId, string $singleId): Data


/**
* @param string $emulated
* @param string $emulated by default, userId; can be an entity using singleId=<singleId>
*
* @throws FederatedUserException
* @throws FederatedUserNotFoundException
Expand All @@ -543,6 +541,18 @@ public function link(string $emulated, string $circleId, string $singleId): Data
private function setLocalFederatedUser(string $emulated): void {
$user = $this->userSession->getUser();
$this->federatedUserService->setCurrentPatron($user->getUID());

if (strpos($emulated, '=') > 0) {
[$type, $id] = explode('=', $emulated, 2);
switch (strtolower($type)) {
case 'singleid':
ArtificialOwl marked this conversation as resolved.
Show resolved Hide resolved
$federatedUser = $this->federatedUserService->getFederatedUser($id, Member::TYPE_SINGLE);
$this->federatedUserService->setCurrentUser($federatedUser);
break;
}

return;
}
$this->federatedUserService->setLocalCurrentUserId($emulated);
}
}