Skip to content

Commit

Permalink
Merge pull request #94 from thucke/Bugfix-#93
Browse files Browse the repository at this point in the history
Bugfix #93
  • Loading branch information
thucke committed Feb 19, 2021
2 parents 2d93763 + e703b57 commit f01d659
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
28 changes: 17 additions & 11 deletions Classes/Service/AccessControlService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use Thucke\ThRating\Exception\FeUserNotFoundException;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use \Thucke\ThRating\Domain\Model\Voter;
Expand Down Expand Up @@ -68,6 +67,18 @@ public function injectVoterRepository(\Thucke\ThRating\Domain\Repository\VoterRe
$this->voterRepository = $voterRepository;
}

/**
* @var \TYPO3\CMS\Core\Context\Context $context
*/
protected $context;
/**
* @param \TYPO3\CMS\Core\Context\Context $context
*/
public function injectContext(\TYPO3\CMS\Core\Context\Context $context): void
{
$this->context = $context;
}

/**
* Tests, if the given person is logged into the frontend
*
Expand All @@ -86,7 +97,6 @@ public function isLoggedIn(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $person
return true; //treat anonymous user also as logged in
}
}

return false;
}

Expand All @@ -96,9 +106,7 @@ public function isLoggedIn(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $person
*/
public function backendAdminIsLoggedIn(): bool
{
/** @var Context $context */
$context = GeneralUtility::makeInstance(Context::class, null);
return $context->getPropertyFromAspect('backend.user', 'isLoggedIn');
return $this->context->getPropertyFromAspect('backend.user', 'isLoggedIn');
}

/**
Expand All @@ -108,8 +116,7 @@ public function backendAdminIsLoggedIn(): bool
public function hasLoggedInFrontendUser(): bool
{
/** @var Context $context */
$context = GeneralUtility::makeInstance(Context::class, array());
return $context->getPropertyFromAspect('frontend.user', 'isLoggedIn');
return $this->context->getPropertyFromAspect('frontend.user', 'isLoggedIn');
}

/**
Expand All @@ -119,9 +126,8 @@ public function hasLoggedInFrontendUser(): bool
public function getFrontendUserGroups(): array
{
if ($this->hasLoggedInFrontendUser()) {
return $GLOBALS['TSFE']->fe_user->groupData['uid'];
return $this->context->getPropertyFromAspect('frontend.user', 'groupIds');
}

return [];
}

Expand All @@ -131,8 +137,8 @@ public function getFrontendUserGroups(): array
*/
public function getFrontendUserUid(): ?int
{
if ($this->hasLoggedInFrontendUser() && !empty($GLOBALS['TSFE']->fe_user->user['uid'])) {
return (int)$GLOBALS['TSFE']->fe_user->user['uid'];
if ($this->hasLoggedInFrontendUser()) {
return $this->context->getPropertyFromAspect('frontend.user', 'id');
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'title' => 'Rating AX',
'description' => 'Highly flexible AJAX rating based on extbase/fluid/jquery. Allows multiple ratings within one page. Could be used as a cObj by other extensions or included in every FLUID template using the viewhelper. Each ratingstep could be configured having a name - international localization included.',
'category' => 'misc',
'version' => '1.8.2',
'version' => '1.8.3',
'state' => 'stable',
'uploadfolder' => false,
'createDirs' => '',
Expand Down

0 comments on commit f01d659

Please sign in to comment.