jeudi 28 mars 2019

Laravel 5.5 secure Rich File Manager in API ( using User auth )

i have application in laravel 5.5 i using RichFileManager (https://github.com/servocoder/RichFilemanager-PHP/wiki/Laravel-framework). I want give permission to use this only logged users. I create in routes/api.php implementation (as in documentation).

Route::match(['get', 'post'], '/filemanager', function (Request $request) 
{
    require_once base_path('public/RichFilemanager/connectors/php/events.php');

    function fm_authenticate()

    {
        return true;
    }

    function fm_has_read_permission($filepath)
    {
        // Customize this code as desired.
        return true;
    }

    function fm_has_write_permission($filepath)
    {
        // Customize this code as desired.
        return true;
    }


    $app = new \RFM\Application();

    // uncomment to use events
    $app->registerEventsListeners();

    $local = new \RFM\Repository\Local\Storage($config);

    // example to setup files root folder
    $path = app()->basePath() . '/public/filemanager';
    $local->setRoot($path, true, false);

    $app->setStorage($local);

    // set application API
    $app->api = new RFM\Api\LocalApi();

    $app->run(); });

My question is how can i use Auth::check() in fm_authenticate function in this place (routes/api.php) ?

When i use middleware auth this show mi login panel but it's not working because currently I logged in.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2FxlwqF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire