I am developing a custom authentication plugin for Craft 3. But I can't route to my Controller via POST
request with my login form. Request via GET
work
-
Have you a problem with Csrf? Or can you specify more precisely what's your problem.– lenkaCommented Oct 17, 2018 at 13:03
-
Can you add some additional details? As your question currently stands, it's far to broad to know what the problem may be.– Lindsey DCommented Oct 17, 2018 at 18:53
Add a comment
|
1 Answer
Although your question is lacking in detail, here is a shot at helping you track down the issue. The fact that GET requests are working but POST requests are not, your form is likely missing a CSRF token. You can add it to your form using the following twig code:
<form method="post" action="">
{{ csrfInput() }}
If your POST request is coming through as an AJAX request then you can create and submit a CSRF token as described in this answer.