@@ -19,8 +19,20 @@ public function __construct($storage_path, $helper)
1919
2020 public function __call ($ function_name , $ arguments )
2121 {
22- // TODO: check function exists
23- return $ this ->disk ->$ function_name ($ this ->path , ...$ arguments );
22+ if ($ function_name == 'directories ' ) {
23+ $ directories = $ this ->disk ->directories ($ this ->path , ...$ arguments );
24+ $ config = $ this ->helper ->config ('private_folder_name ' );
25+
26+ if (method_exists (app ()->make ($ config ), 'userAuthDirs ' )) {
27+ return $ this ->getAuthDirectories ($ directories , app ()->make ($ config )->userAuthDirs ());
28+ } else {
29+ return $ directories ;
30+ }
31+
32+ } else {
33+ // TODO: check function exists
34+ return $ this ->disk ->$ function_name ($ this ->path , ...$ arguments );
35+ }
2436 }
2537
2638 public function rootPath ()
@@ -62,4 +74,20 @@ public function extension()
6274 setlocale (LC_ALL , 'en_US.UTF-8 ' );
6375 return pathinfo ($ this ->path , PATHINFO_EXTENSION );
6476 }
77+
78+ public function getAuthDirectories ($ directories , $ auth_dirs )
79+ {
80+ $ check = $ directories ;
81+
82+ if (count ($ auth_dirs )){
83+ // remove unauthorized directories
84+ foreach ($ check as $ i => $ directory ) {
85+ if (!in_array ($ directory , $ auth_dirs )){
86+ unset($ directories [$ i ]);
87+ }
88+ }
89+ }
90+
91+ return $ directories ;
92+ }
6593}
0 commit comments