In TYPO3 11 LTS I've created a custom FE extension which generates a custom login process. For that I've provided an auth
Service with 2 subtypes in ext_localconf.php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addService(
// Extension Key
'mylogin',
// Service type
'auth',
// Service key
'tx_mylogin_login_process_data',
// Info
array(
'subtype' => 'processLoginDataFE,authUserFE',
'available' => true,
'title' => 'Mylogin Authentication',
'description' => 'Services for my login',
'priority' => 85,
'quality' => 85,
'os' => '',
'exec' => '',
'className' => MyLoginAuthenticatorService::class
)
);
MyLoginAuthenticatorService extends TYPO3\CMS\Core\Authentication\AuthenticationService
.
Inside MyLoginAuthenticatorService::processLoginData(array &$loginData, $passwordTransmissionStrategy)
I check for certain credentials and overwrite the $loginData
with the username found by a login_key
.
Inside MyLoginAuthenticatorService::authUser(array $user)
I get the right/expected fe user array (like in the normal fe_login process). In here I check for a certain circumstance and return an integer 200.
Doing that with some debug I can confirm that I am reaching the point in code with the return 200;
and as mentioned above having a filled array with user credentials.
In my extension I use the following Fluid form:
<f:form method="post" action="customlogin" fieldNamePrefix="">
<f:form.hidden name="user" value="{login_key}" />
<f:form.hidden name="pass" value="" />
<f:form.hidden name="logintype" value="login" />
<f:form.hidden name="pid" value="{secure_pid}" />
<f:form.button type="submit">Login</f:form.button>
</f:form>
Now the problem: Without the registered service I can access the customloginAction
in my controller. Putting back the service registration after the return 200; my frontend returns:
#1313855173 TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerNameException
The controller "Mycontrollername" is not allowed by plugin "Myloginplugin".
Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin()
in your ext_localconf.php.
The plugin is the same as the form action and the resulting action is placed in and as mentioned above it all works without the services.
So what is wrong? Is using the auth services even the right way? What do I miss? Is returning 200 in authUserFE enough to trigger all stuff TYPO3 has to do to provide a logged in user?
Edit:
I've found out that going with a <form action="/" ...>
the whole solution works perfectly. That form is on the subpage /login. If I do the action="/login" the mentioned InvalidControllerNameException
pops up again.
Do you know why that could happen?
Got it.
It was a deep dive into code / understand what you use problem. Inside my custom AuthenticationService functions I used some functionality right from the ActionController of my custom auth extension.
This causes TYPO3 to build an additional request with no context resulting in the error above. After removing the ActionController stuff from the service context everything works like charm. Yes even with that fluid form:
<f:form method="post" action="customlogin" fieldNamePrefix="">
<f:form.hidden name="user" value="{login_key}" />
<f:form.hidden name="pass" value="" />
<f:form.hidden name="logintype" value="login" />
<f:form.hidden name="pid" value="{secure_pid}" />
<f:form.button type="submit">Login</f:form.button>
</f:form>