Skip to content

Commit

Permalink
Merge pull request #995 from nextcloud/fix/collabora-not-loading
Browse files Browse the repository at this point in the history
fix(office): getUser from userSession
  • Loading branch information
GretaD authored Oct 16, 2024
2 parents 752480a + 37ee294 commit 1c045a7
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions lib/Checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
use OCP\IRequest;
use OCP\ISession;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\IL10N;
use Psr\Log\LoggerInterface;

class Checker {
/** @var string */
private $userId;
/** @var IRequest */
private $request;
/** @var IUserManager */
private $userManager;
/** @var IUserSession */
private $userSession;
/** @var ISession */
private $session;
/** @var SignatoryMapper */
Expand All @@ -42,9 +40,8 @@ class Checker {
private $termsCache = [];

public function __construct(
?string $userId,
IRequest $request,
IUserManager $userManager,
IUserSession $userSession,
ISession $session,
SignatoryMapper $signatoryMapper,
TermsMapper $termsMapper,
Expand All @@ -53,9 +50,8 @@ public function __construct(
IL10N $l10n,
LoggerInterface $logger
) {
$this->userId = $userId;
$this->request = $request;
$this->userManager = $userManager;
$this->userSession = $userSession;
$this->session = $session;
$this->signatoryMapper = $signatoryMapper;
$this->termsMapper = $termsMapper;
Expand All @@ -77,7 +73,7 @@ public function getForbiddenMessage(): string {
*/
public function currentUserHasSigned(): bool {
$uuid = $this->config->getAppValue(Application::APPNAME, 'term_uuid', '');
if ($this->userId === null) {
if ($this->userSession->getUser() === null) {
if ($this->config->getAppValue(Application::APPNAME, 'tos_on_public_shares', '0') === '0') {
return true;
}
Expand Down Expand Up @@ -105,11 +101,7 @@ public function currentUserHasSigned(): bool {
return true;
}

if ($this->userId === null) {
return false;
}

$user = $this->userManager->get($this->userId);
$user = $this->userSession->getUser();
if (!$user instanceof IUser) {
return false;
}
Expand Down

0 comments on commit 1c045a7

Please sign in to comment.