Bug #99131
closedCannot use repository methods in Authentication service 11.5 anymore
0%
Description
I am upgrading from 9.5 to 11.5 an AuthenticationService class with getUser() for frontend login
When I try to use a repository to add or update some objects I get
The controller "Login" is not allowed by plugin "Login". Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.
When debugging the Repository methods work fine and the objects are updated in the database. I am now forced to use queryBuilder which is not very easy for updating sys_refindex relations.
Updated by Christian Kuhn about 2 years ago
- Status changed from New to Needs Feedback
Hey. Thanks for your report.
Your description is a bit hard to understand and follow, I don't understand what is going on.
Could you add some code, including your service registration and a stripped down implementation that can be used to trigger your issue?
Updated by Jacco van der Post about 2 years ago
Hey Christian,
See here a simple code example of AuthenticationService.php.
<?php
namespace Xxx\Xxxauth\Service;
use Xxx\Xxxauth\Domain\Repository\BankaccountRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class AuthenticationService extends \TYPO3\CMS\Core\Authentication\AuthenticationService
{
// We cannot use construct here:
// Too few arguments to function Xxx\Xxxauth\Service\AuthenticationService::__construct(), 0 passed in /Users/jaccovanderpost/Sites/Xxxned.test/public/typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 3221 and exactly 1 expected
// protected BankaccountRepository $bankaccountRepository;
//
// public function __construct(
// BankaccountRepository $bankaccountRepository
// )
// {
// $this->bankaccountRepository = $bankaccountRepository;
// }
public function getUser()
{
$bankaccountRepository = GeneralUtility::makeInstance(BankaccountRepository::class);
$test = $bankaccountRepository->findByUid(1);
// DebuggerUtility::var_dump($test);
// exit();
}
}
This results in the fe_login error mentioned above. When removing the repository lines or using QueryBuilder instead, the login process continues and the user is logged in. When removing the comments before var_dump the output is correct.
In 9.5 it was no problem to use repositories in an AuthenticationService.
In ext_localconf.php:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addService(
'xxxauth',
'auth',
\Xxx\Xxxauth\Service\AuthenticationService::class,
[
'title' => 'Authentication service',
'description' => 'Authentication Lookup at XxxWorldWide',
'subtype' => 'getUserFE, authUserFE, getGroupsFE',
'available' => true,
'priority' => 90,
'quality' => 90,
'os' => '',
'exec' => '',
'className' => \Xxx\Xxxauth\Service\AuthenticationService::class
]
);
Updated by Georg Ringer 5 months ago
- Status changed from Needs Feedback to Rejected
hey!
thanks for the detailed report. I am closing this as won't fix. using repositories from extbase is not what you should do at this point of time. please use the querybuilder as you already tested it.