| Total Complexity | 7 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class MultiUser |
||
| 9 | { |
||
| 10 | public function handle($request, Closure $next) |
||
| 11 | { |
||
| 12 | if (\Config::get('lfm.allow_multi_user') === true) { |
||
| 13 | $slug = \Config::get('lfm.user_field'); |
||
| 14 | |||
| 15 | $new_working_dir = '/' . CRUDBooster::myId(); |
||
| 16 | |||
| 17 | $previous_dir = $request->input('working_dir'); |
||
| 18 | |||
| 19 | if ($previous_dir == null) { |
||
| 20 | $request->merge(['working_dir' => $new_working_dir]); |
||
| 21 | } elseif (! $this->validDir($previous_dir)) { |
||
| 22 | $request->replace(['working_dir' => $new_working_dir]); |
||
| 23 | } |
||
| 24 | } |
||
| 25 | |||
| 26 | return $next($request); |
||
| 27 | } |
||
| 28 | |||
| 29 | private function validDir($previous_dir) |
||
| 30 | { |
||
| 31 | if (starts_with($previous_dir, '/' . \Config::get('lfm.shared_folder_name'))) { |
||
| 32 | return true; |
||
| 33 | } |
||
| 34 | |||
| 35 | if (starts_with($previous_dir, '/' . CRUDBooster::myId() )) { |
||
| 36 | return true; |
||
| 37 | } |
||
| 38 | |||
| 39 | return false; |
||
| 40 | } |
||
| 42 |