Skip to content
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
emulate entity on Admin OCS API
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Nov 23, 2022
commit 5b26f6c133c2d172c38466ecac6ac0f417778008
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':
$federatedUser = $this->federatedUserService->getFederatedUser($id, Member::TYPE_SINGLE);
$this->federatedUserService->setCurrentUser($federatedUser);
break;
}

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