Can you please tell me how in Laravel 5.6 you can check whether a user is authorized on the site when sending a request through the API? That is, you need before auth: api authorizes the user by token to check whether he is authorized on the site.

  • one
    Maybe I did not understand the question, but the meaning of authorization by token is to understand whether a user is authorized or not. In the token there is the necessary information that the API decrypts and draws the appropriate conclusions - zhenyab pm
  • It is necessary to check that only an authorized user sends a request for certain routes, if so, then "auth: api" should authorize it. You need to make sure that he has a session on the site and the token that he sent is valid. - Alexander Fedorov
  • one
    I think you do not quite understand the purpose of the interface api - Maxim K
  • All this makes authorization by token, OAuth2 and similar protocols. If you ask how to implement it on Laravel, then the Internet is full of articles on this topic. - zhenyab 2:46 pm
  • API is used to access data from any application, authorization by token. But if you need to process requests based on the user - use routes other than /api/** , where there is a group of web intermediaries. There you can find out the user by \Auth::user() - Maxim K

0