K
K
koliane2018-07-29 15:12:33
Laravel
koliane, 2018-07-29 15:12:33

How to find out information about the current user in October CMS?

An authorized user clicks a button on a certain page, thereby sending an ajax request, which is processed in the plugin in the routes.php file. There, I have to get the user's data via the command Auth::getUser();, but it returns NULL even though the current user is authorized.
Why is the command Auth::getUser(); can produce NULL and how can I still get information about the user in my case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
koliane, 2018-08-02
@koliane

For those who also have the same question:
In the routes.php file, you need to connect an intermediary (middleware) web
I.e., the code will look like this:

Route::post( $path, ['middleware' => 'web',function(){
    echo Auth::getUser()->id;
}]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question