Elfinder access related folder structure for each logged in user #1247
Replies: 3 comments
-
Your question is about restricting folder access in elFinder for logged-in users in Backpack. This is a relevant topic for Backpack, so I'll do my best to answer based on the available information. The approach you're taking to configure elFinder roots dynamically based on the logged-in user is generally correct. However, there are a few things to consider:
Here's a suggestion based on the available information:
'roots' => [
[
'driver' => 'LocalFileSystem',
'path' => storage_path('user/' . (backpack_user() ? backpack_user()->id : '')),
'URL' => url('storage/user/' . (backpack_user() ? backpack_user()->id : '')),
'accessControl' => 'App\Http\Middleware\ElfinderAccess::checkAccess',
],
],
<?php
namespace App\Http\Middleware;
class ElfinderAccess
{
public static function checkAccess($attr, $path, $data, $volume)
{
$user = backpack_user();
if (!$user) {
return false;
}
$userFolder = storage_path("user/{$user->id}");
return strpos($path, $userFolder) === 0 ? null : !($attr == 'read' || $attr == 'write');
}
}
This approach is based on the suggestions found in the Github issue about elFinder access control and another issue about restricting elFinder access. Remember to create the necessary folders in your storage directory for each user. If this doesn't solve your problem, you might need to provide more details about your specific setup and where exactly you're encountering issues. The Backpack community forum might also be a good place to ask for more specific help. ℹ️ Please note our AI Bot does not reply to follow-ups, this will be the only AI answer in this thread. If the AI helped you find the answer, please mark it as answered or write details below so it can learn. Then close the conversation. If not, please give more information for when a human reads this. ℹ️ Relevant sources: Github Issue (open): [Feature Request] Browser field: restrict to subdirectories |
Beta Was this translation helpful? Give feedback.
-
Due to not activity, I will close this issue, but please feel free to re-open or create a new one if needed. Cheers. |
Beta Was this translation helpful? Give feedback.
-
that solution did not help at all |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
guys I've been spending sometime about restricting folder structure for the logged in users id based, but I cant achieve it somehow, is there anyone worked with this feature of elfinder ?
I have a static method that I initialize from the controller where I use this settings ( tried with appserviceprovider too but no success )
so the code sample is as below;
any help suggestions ?
Beta Was this translation helpful? Give feedback.
All reactions