Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use dependency injection
Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan authored and backportbot[bot] committed Mar 11, 2022
commit c3be6faadf53d1dab100c7b38e5a2e6bb21ba9e5
12 changes: 7 additions & 5 deletions lib/Controller/RemoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class RemoteController extends Controller {
/** @var ConfigService */
private $configService;

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

/**
* RemoteController constructor.
Expand Down Expand Up @@ -136,7 +138,8 @@ public function __construct(
MemberService $memberService,
MembershipService $membershipService,
InterfaceService $interfaceService,
ConfigService $configService
ConfigService $configService,
IUserSession $userSession
) {
parent::__construct($appName, $request);
$this->circleRequest = $circleRequest;
Expand All @@ -148,6 +151,7 @@ public function __construct(
$this->membershipService = $membershipService;
$this->interfaceService = $interfaceService;
$this->configService = $configService;
$this->userSession = $userSession;

$this->setup('app', 'circles');
$this->setupArray('enforceSignatureHeaders', ['digest', 'content-length']);
Expand Down Expand Up @@ -550,8 +554,7 @@ public function exceptionResponse(
*/
private function publicPageJsonLimited(): void {
if (!$this->jsonRequested()) {
if (!OC::$server->get(IUserSession::class)
->isLoggedIn()) {
if (!$this->userSession->isLoggedIn()) {
throw new NotLoggedInException();
}

Expand Down Expand Up @@ -580,8 +583,7 @@ private function jsonRequested(): bool {
* @return bool
*/
private function areWithinAcceptHeader(array $needles): bool {
$request = OC::$server->get(IRequest::class);
$accepts = array_map([$this, 'trimHeader'], explode(',', $request->getHeader('Accept')));
$accepts = array_map([$this, 'trimHeader'], explode(',', $this->request->getHeader('Accept')));

foreach ($accepts as $accept) {
if (in_array($accept, $needles)) {
Expand Down