Update
This commit is contained in:
@@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Response;
|
||||
use ZipArchive;
|
||||
use JsonMachine\Items;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Log;
|
||||
class JsonTransferController extends Controller
|
||||
{
|
||||
protected $exportPath = 'database/seeders/data/';
|
||||
@@ -148,14 +148,26 @@ class JsonTransferController extends Controller
|
||||
return back()->with('error', "Error 500 Details: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function pull(Request $request){
|
||||
public function pull(Request $request)
|
||||
{
|
||||
if (session('previlage') !== 'developer') {
|
||||
abort(403, 'Akses ditolak. Anda tidak memiliki izin untuk menjalankan git pull.');
|
||||
Log::warning('Unauthorized pull attempt by user: ' . (auth()->check() ? auth()->user()->email : 'Guest') . ' at ' . now());
|
||||
$output = "Unauthorized access. You do not have permission to perform this action.";
|
||||
}
|
||||
|
||||
$gitPath = base_path();
|
||||
$output = shell_exec("cd {$gitPath} && git pull 2>&1");
|
||||
|
||||
$command = "cd {$gitPath} && " .
|
||||
"git fetch origin 2>&1 && " .
|
||||
"git reset --hard origin/main 2>&1 && " .
|
||||
"git clean -fd 2>&1 && " .
|
||||
"php artisan config:cache 2>&1 && " .
|
||||
"php artisan optimize:clear 2>&1";
|
||||
|
||||
$output = shell_exec($command);
|
||||
|
||||
if (auth()->check()) {
|
||||
Log::info('Git pull executed by user: ' . auth()->user()->email.' at '.now());
|
||||
Log::info('Force pull & optimize executed by user: ' . auth()->user()->email . ' at ' . now());
|
||||
}
|
||||
|
||||
return back()->with('git_output', $output);
|
||||
|
||||
Reference in New Issue
Block a user