mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-19 21:10:49 +01:00
Correzioni per retro-compatibilità API
This commit is contained in:
parent
2f2e59e325
commit
c1b3b1f118
@ -50,7 +50,10 @@ class InfoController extends Controller
|
|||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
$token = auth()->getToken();
|
$user = auth()->user();
|
||||||
|
|
||||||
|
$tokens = $user->getApiTokens();
|
||||||
|
$token = $tokens[0]['token'];
|
||||||
|
|
||||||
$api = BASEURL.'/api/?token='.$token;
|
$api = BASEURL.'/api/?token='.$token;
|
||||||
|
|
||||||
|
@ -5,19 +5,30 @@ namespace App\Http\Controllers;
|
|||||||
use App\Exceptions\LegacyExitException;
|
use App\Exceptions\LegacyExitException;
|
||||||
use App\Exceptions\LegacyRedirectException;
|
use App\Exceptions\LegacyRedirectException;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Redirect;
|
use Illuminate\Support\Facades\Redirect;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
class LegacyController extends Controller
|
class LegacyController extends Controller
|
||||||
{
|
{
|
||||||
public function index($path = 'index.php')
|
public function index(Request $request, $path = 'index.php')
|
||||||
{
|
{
|
||||||
$base_path = base_path('legacy');
|
$base_path = base_path('legacy');
|
||||||
|
|
||||||
|
// Fix per redirect all'API
|
||||||
|
$api_request = false;
|
||||||
|
if (in_array($path, ['api', 'api/', 'api/index.php'])) {
|
||||||
|
$path = 'api/index.php';
|
||||||
|
$api_request = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ricerca del file interessato
|
||||||
$file = realpath($base_path.'/'.$path);
|
$file = realpath($base_path.'/'.$path);
|
||||||
if (strpos($file, $base_path) === false) {
|
if (strpos($file, $base_path) === false) {
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inclusione diretta del file
|
||||||
ob_start();
|
ob_start();
|
||||||
try {
|
try {
|
||||||
require $file;
|
require $file;
|
||||||
@ -26,13 +37,17 @@ class LegacyController extends Controller
|
|||||||
return Redirect::to($e->getMessage());
|
return Redirect::to($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gestione dell'output
|
||||||
$output = ob_get_clean();
|
$output = ob_get_clean();
|
||||||
|
|
||||||
$response = response($output);
|
$response = response($output);
|
||||||
|
|
||||||
// Fix content-type per contenuti non HTML
|
// Fix content-type per contenuti non HTML
|
||||||
if (ends_with($path, '.js')) {
|
if (ends_with($path, '.js')) {
|
||||||
$response = $response->header('Content-Type', 'application/javascript');
|
$response = $response->header('Content-Type', 'application/javascript');
|
||||||
|
} elseif (string_contains($path, 'pdfgen.php')) {
|
||||||
|
$response = $response->header('Content-Type', 'application/pdf');
|
||||||
|
} elseif ($api_request) {
|
||||||
|
$response = $response->header('Content-Type', 'application/json');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -42,14 +42,13 @@
|
|||||||
"laravel/framework": "^8.12",
|
"laravel/framework": "^8.12",
|
||||||
"laravel/tinker": "^2.5",
|
"laravel/tinker": "^2.5",
|
||||||
"league/csv": "^8.2",
|
"league/csv": "^8.2",
|
||||||
"mpdf/mpdf": "^v8.0.7",
|
"mpdf/mpdf": "^8.0.10",
|
||||||
"mpociot/vat-calculator": "^2.3",
|
"mpociot/vat-calculator": "^2.3",
|
||||||
"nwidart/laravel-modules": "^8.2",
|
"nwidart/laravel-modules": "^8.2",
|
||||||
"owasp/csrf-protector-php": "^1.0",
|
"owasp/csrf-protector-php": "^1.0",
|
||||||
"phpmailer/phpmailer": "^6.0",
|
"phpmailer/phpmailer": "^6.0",
|
||||||
"respect/validation": "^1.1",
|
"respect/validation": "^1.1",
|
||||||
"servo/fluidxml": "^1.21",
|
"servo/fluidxml": "^1.21",
|
||||||
"spipu/html2pdf": "^5.0",
|
|
||||||
"symfony/polyfill-ctype": "^1.8",
|
"symfony/polyfill-ctype": "^1.8",
|
||||||
"symfony/polyfill-php70": "^1.8",
|
"symfony/polyfill-php70": "^1.8",
|
||||||
"willdurand/geocoder": "^3.3",
|
"willdurand/geocoder": "^3.3",
|
||||||
|
@ -16,6 +16,10 @@ Route::get('/login', [AuthenticatedSessionController::class, 'create'])
|
|||||||
Route::post('/login', [AuthenticatedSessionController::class, 'store'])
|
Route::post('/login', [AuthenticatedSessionController::class, 'store'])
|
||||||
->middleware('guest');
|
->middleware('guest');
|
||||||
|
|
||||||
|
Route::get('/logout', [AuthenticatedSessionController::class, 'destroy'])
|
||||||
|
->middleware('auth')
|
||||||
|
->name('logout');
|
||||||
|
|
||||||
Route::get('/forgot-password', [PasswordResetLinkController::class, 'create'])
|
Route::get('/forgot-password', [PasswordResetLinkController::class, 'create'])
|
||||||
->middleware('guest')
|
->middleware('guest')
|
||||||
->name('password.request');
|
->name('password.request');
|
||||||
@ -50,7 +54,3 @@ Route::get('/confirm-password', [ConfirmablePasswordController::class, 'show'])
|
|||||||
|
|
||||||
Route::post('/confirm-password', [ConfirmablePasswordController::class, 'store'])
|
Route::post('/confirm-password', [ConfirmablePasswordController::class, 'store'])
|
||||||
->middleware('auth');
|
->middleware('auth');
|
||||||
|
|
||||||
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])
|
|
||||||
->middleware('auth')
|
|
||||||
->name('logout');
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user