mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-25 02:10:22 -06:00
Demo user is no longer capable of uploading files.
This commit is contained in:
parent
6c5499e848
commit
9ff9385c47
@ -368,14 +368,30 @@ class ImportController extends Controller
|
|||||||
$content = $uploaded->fread($uploaded->getSize());
|
$content = $uploaded->fread($uploaded->getSize());
|
||||||
$contentEncrypted = Crypt::encrypt($content);
|
$contentEncrypted = Crypt::encrypt($content);
|
||||||
$disk = Storage::disk('upload');
|
$disk = Storage::disk('upload');
|
||||||
$disk->put($newName, $contentEncrypted);
|
|
||||||
|
|
||||||
Log::debug('Uploaded file', ['name' => $upload->getClientOriginalName(), 'size' => $upload->getSize(), 'mime' => $upload->getClientMimeType()]);
|
// user is demo user, replace upload with prepared file.
|
||||||
|
if (auth()->user()->hasRole('demo')) {
|
||||||
|
$stubsDisk = Storage::disk('stubs');
|
||||||
|
$content = $stubsDisk->get('demo-import.csv');
|
||||||
|
$contentEncrypted = Crypt::encrypt($content);
|
||||||
|
$disk->put($newName, $contentEncrypted);
|
||||||
|
Log::debug('Replaced upload with demo file.');
|
||||||
|
|
||||||
// store configuration file's content into the job's configuration
|
// also set up prepared configuration.
|
||||||
// thing.
|
$configuration = json_decode($stubsDisk->get('demo-configuration.json'), true);
|
||||||
// otherwise, leave it empty.
|
$job->configuration = $configuration;
|
||||||
if ($request->files->has('configuration_file')) {
|
$job->save();
|
||||||
|
Log::debug('Set configuration for demo user', $configuration);
|
||||||
|
}
|
||||||
|
if (!auth()->user()->hasRole('demo')) {
|
||||||
|
// user is not demo, process original upload:
|
||||||
|
$disk->put($newName, $contentEncrypted);
|
||||||
|
Log::debug('Uploaded file', ['name' => $upload->getClientOriginalName(), 'size' => $upload->getSize(), 'mime' => $upload->getClientMimeType()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// store configuration file's content into the job's configuration thing. Otherwise, leave it empty.
|
||||||
|
// demo user's configuration upload is ignored completely.
|
||||||
|
if ($request->files->has('configuration_file') && !auth()->user()->hasRole('demo')) {
|
||||||
/** @var UploadedFile $configFile */
|
/** @var UploadedFile $configFile */
|
||||||
$configFile = $request->files->get('configuration_file');
|
$configFile = $request->files->get('configuration_file');
|
||||||
Log::debug(
|
Log::debug(
|
||||||
@ -394,6 +410,9 @@ class ImportController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if user is demo user, replace config with prepared config:
|
||||||
|
|
||||||
|
|
||||||
return redirect(route('import.configure', [$job->key]));
|
return redirect(route('import.configure', [$job->key]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,11 @@ return [
|
|||||||
'driver' => 'local',
|
'driver' => 'local',
|
||||||
'root' => base_path('resources/seeds'),
|
'root' => base_path('resources/seeds'),
|
||||||
],
|
],
|
||||||
|
'stubs' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => base_path('resources/stubs'),
|
||||||
|
],
|
||||||
|
|
||||||
'public' => [
|
'public' => [
|
||||||
'driver' => 'local',
|
'driver' => 'local',
|
||||||
'root' => storage_path('app/public'),
|
'root' => storage_path('app/public'),
|
||||||
|
Loading…
Reference in New Issue
Block a user