added it_get_public_file_record_and_download_them, it_try_to_get_protected_file_record, it_get_shared_record, it_get_deleted_shared_record, it_get_shared_page, it_get_deleted_shared_page test

This commit is contained in:
Peter Papp
2021-03-10 08:41:21 +01:00
parent e164d1021c
commit aecdf56304
14 changed files with 195 additions and 41 deletions

View File

@@ -26,16 +26,21 @@ class FileSharingController extends Controller
/**
* Show page index and delete access_token & shared_token cookie
*
* @return Factory|\Illuminate\View\View
* @return \Illuminate\Http\Response
*/
public function index($token)
{
// Get shared token
$shared = Share::where(\DB::raw('BINARY `token`'), $token)
$shared = Share::whereToken($token)
->first();
if (! $shared) {
return view("index");
return response()
->view('index', [
'settings' => null,
'legal' => null,
'installation' => null,
], 404);
}
// Delete old access_token if exist
@@ -196,16 +201,17 @@ class FileSharingController extends Controller
public function file_public($token)
{
// Get sharing record
$shared = Share::where(DB::raw('BINARY `token`'), $token)->firstOrFail();
$shared = Share::whereToken($token)
->firstOrFail();
// Abort if file is protected
if ((int) $shared->protected) {
if ((int) $shared->is_protected) {
abort(403, "Sorry, you don't have permission");
}
// Get file
$file = File::where('user_id', $shared->user_id)
->where('unique_id', $shared->item_id)
->where('id', $shared->item_id)
->firstOrFail(['name', 'basename', 'thumbnail', 'type', 'filesize', 'mimetype']);
// Set urls