Skip to content

Commit

Permalink
retrieve user from session
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl authored and backportbot[bot] committed Aug 10, 2021
1 parent 965a512 commit 410baa9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 11 additions & 2 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
use OCP\IUserSession;


/**
Expand All @@ -54,6 +55,9 @@ class ApiController extends Controller {
use TNCDataResponse;


/** @var IUserSession */
private $userSession;

/** @var SearchService */
private $searchService;

Expand All @@ -68,15 +72,19 @@ class ApiController extends Controller {
* NavigationController constructor.
*
* @param IRequest $request
* @param IUserSession $userSession
* @param ConfigService $configService
* @param SearchService $searchService
* @param MiscService $miscService
*/
public function __construct(
IRequest $request, ConfigService $configService, SearchService $searchService,
IRequest $request, IUserSession $userSession, ConfigService $configService,
SearchService $searchService,
MiscService $miscService
) {
parent::__construct(Application::APP_ID, $request);

$this->userSession = $userSession;
$this->searchService = $searchService;
$this->configService = $configService;
$this->miscService = $miscService;
Expand Down Expand Up @@ -117,7 +125,8 @@ public function searchFromRemote(string $request): DataResponse {
*/
private function searchDocuments(SearchRequest $request): DataResponse {
try {
$result = $this->searchService->search('', $request);
$user = $this->userSession->getUser();
$result = $this->searchService->search($user->getUID(), $request);

return $this->success(
$result,
Expand Down
4 changes: 0 additions & 4 deletions lib/Service/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ public function generateSearchRequest(array $request): ISearchRequest {
public function search(string $userId, ISearchRequest $request): array {
$this->searchRequestCannotBeEmpty($request);

if ($userId === '') {
$userId = $this->userId;
}

$user = $this->userManager->get($userId);
if ($user === null) {
throw new NoUserException('User does not exist');
Expand Down

0 comments on commit 410baa9

Please sign in to comment.