Contao 4 Front-end login does not work like contao 3.5

208 Views Asked by At

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

There are 1 best solutions below

2
fritzmg On

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.