Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(office): getUser from userSession #995

Merged
merged 1 commit into from
Oct 16, 2024
Merged
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
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
Loading