0

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.

1 Answer 1

0

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.

2
  • 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.
    – mrana
    Commented Sep 24, 2021 at 11:16
  • Then you might need to implement a Guard Authenticator: symfony.com/doc/4.4/security/guard_authentication.html
    – fritzmg
    Commented Sep 24, 2021 at 12:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.