Skip to content

Commit

Permalink
fix: 更新 composer.json,添加 dev 依赖;优化 ConfigProvider 和 Authorize 类的代码
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia committed Dec 2, 2024
1 parent 20d00ad commit 24f9c14
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"web-tinker",
"hyperf",
"tinker",
"dev",
"debug",
"development"
],
Expand Down
12 changes: 0 additions & 12 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ public function __invoke()
'source' => __DIR__ . '/../publish/web-tinker.php',
'destination' => BASE_PATH . '/config/autoload/web-tinker.php',
],
// [
// 'id' => 'view',
// 'description' => 'The view for web-tinker.',
// 'source' => __DIR__ . '/../resources/views/web-tinker.blade.php',
// 'destination' => BASE_PATH . '/resources/views/vendor/web-tinker/web-tinker.blade.php',
// ],
// [
// 'id' => 'assets',
// 'description' => 'The assets for web-tinker.',
// 'source' => __DIR__ . '/../publish/assets',
// 'destination' => BASE_PATH . '/public/vendor/web-tinker',
// ],
],
];
}
Expand Down
6 changes: 5 additions & 1 deletion src/Controller/WebTinkerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ public function renderStaticFile(RequestInterface $request, ResponseInterface $r
));

if (! isset($this->staticFiles[$file])) {
if (! $file || ! file_exists($file)) {
if (
! $file // Invalid file
|| str_contains($file, '../') // Prevent directory traversal
|| ! file_exists($file) // File not found
) {
return $response->html('')->withStatus(404);
}
$this->staticFiles[$file] = [
Expand Down
2 changes: 1 addition & 1 deletion src/Listener/RegisterRoutesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class RegisterRoutesListener implements ListenerInterface
{
public function __construct(
protected DispatcherFactory $dispatcherFactory,
protected DispatcherFactory $dispatcherFactory, // Don't remove this line
protected ConfigInterface $config
) {
}
Expand Down
6 changes: 1 addition & 5 deletions src/Middleware/Authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface

protected function allowedToUseTinker(): bool
{
if (! $this->config->get('web-tinker.enabled', false)) {
return false;
}

return true;
return (bool) $this->config->get('web-tinker.enabled', false);
}
}

0 comments on commit 24f9c14

Please sign in to comment.