Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fant0m's avatar

authentication using ajax, validation

Hello, I'm using laravel's defult auth system but I'm sending requests threw ajax. If I am for example on login page and I send some wrong data, it throws me an error into console:

POST http://some.app/auth/login/ 422 (Unprocessable Entity)

but it actually returns some data:

email: ["The email must be a valid email address."]

Same weird acting for registering.

First question: how to fix those status codes?

Second question: how to handle those errors? Just writing data.email and data.password to an user? Isn't there a better solution?

Third question: what about csrf token? I'm sending it with data but it doesn't seem to require that

Thanks

0 likes
2 replies

Please or to participate in this conversation.