I’m receiving ‘The key "_username" must be a string, "NULL" given’ after submitting login form
this is my jsx:
fetch('/signin', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: JSON.stringify({
_username: "test@example.com", // Test email
_password: "your_password" // Test password
})
})
.then((res) => res.json())
and my controller:
#[Route('/signin', name: 'app_login')]
public function login(AuthenticationUtils $authenticationUtils): Response
{
if ($this->getUser()) {
return $this->redirectToRoute('app_dashboard');
}
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->json([
'last_username' => $lastUsername,
'error' => $error ? $error->getMessage() : null,
]
and my security.yaml
form_login:
login_path: /signin
check_path: /signin
enable_csrf: true
secure: auto
Can you please help me with that
You need to sign in to view this answers
Leave feedback about this