Skip to content

Commit

Permalink
emulate entity on Admin OCS API
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Nov 17, 2022
1 parent b6b3409 commit f9a1e7e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 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 @@ -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);
}
}

0 comments on commit f9a1e7e

Please sign in to comment.