Contao 4 suggests to use form to log in to the front-end: https://docs.contao.org/manual/en/layout/module-management/user-modules/
But I am looking for a solution in my own created login module.
I have a user name (email) and password.
I would like to create my own function to log in and log out in the frontend.
Need a solution. please help.
Add a comment
|
1 Answer
Contao's firewall will react to any POST request with the following parameters:
FORM_SUBMIT=tl_login
username=…
password=…
See the ContaoLoginAuthenticationListener (note: it is different in Contao 4.4).
So as long as your own login module causes these POST request parameters to be sent (+ REQUEST_TOKEN
if necessary), then the user should be automatically logged in.
-
Yes, know this. for form submit this is fine. but i need auto-login without submitting the form. For example, I have a URL with some hash code that would auto-login to contao 4. So, no form submit but another solution.– mranaCommented Sep 24, 2021 at 11:16
-
Then you might need to implement a Guard Authenticator: symfony.com/doc/4.4/security/guard_authentication.html– fritzmgCommented Sep 24, 2021 at 12:03