Answer the question
In order to leave comments, you need to log in
How to check if the user is authenticated (laravel) when requesting from the client (js)?
Good day. I need to implement a mechanism for changing user data by sending an asynchronous request from javascript when the value in the input changes. So, when I accept this request on the server, I need to authenticate the user. The server is written in laravel. Tell me how to do it
Answer the question
In order to leave comments, you need to log in
Take a look at Laravel Passport. With the help of it, I did a check on the user.
Do you need to check if the user is authenticated? Check in the usual way, as if the request is not Ajax. With an Ajax request, cookies are transmitted, there is authentication data there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question