Skip to content
This repository was archived by the owner on Sep 8, 2019. It is now read-only.

Commit 6ff798c

Browse files
committed
Include basic handling for improper unique/file IDs.
1 parent f811708 commit 6ff798c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

app/Http/Controllers/FilesController.php

+10
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,14 @@ public function store()
4141

4242
return back();
4343
}
44+
public function get($unique_id, $file_id)
45+
{
46+
if ($unique_id !== auth()->user()->unique_id){
47+
return back();
48+
}
49+
if (! \Storage::disk('public')->exists($unique_id . '/' . $file_id)) {
50+
return back();
51+
}
52+
return \Storage::url($unique_id . '/' . $file_id);
53+
}
4454
}

routes/web.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
Route::get('/home', 'HomeController@index')->name('home');
2121
Route::get('/files', 'FilesController@index')->name('files');
2222
Route::post('/files', 'FilesController@store');
23-
Route::get('/files/{unique_id}/{file_id}', 'FilesController@get');
23+
Route::get('/storage/{unique_id}/{file_id}', 'FilesController@get');

0 commit comments

Comments
 (0)