Skip to content

Commit 55483e6

Browse files
committed
Fix bug [not applying 'auth' middleware]. Add [~] prefix to routes
1 parent c69a398 commit 55483e6

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ php artisan vendor:publish --provider="Infureal\Providers\GuiServiceProvider"
2929
## Running command
3030
By default, you can access this page only when in local environment.
3131

32-
Simply go to `http://you-domain.com/artisan` and here we go!
32+
Simply go to `http://you-domain.com/~artisan` and here we go!
3333
Select needed command from list, fill arguments and options/flags and hit `run` button.
3434

3535
## Issues

config/artisan-gui.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// Show commands only when authenticated
66
'auth' => true,
77

8+
// route prefix -> ~artisan
9+
'prefix' => '~',
10+
811
// Register routes only when local environment
912
'only_local' => true,
1013

routes/web.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
use Infureal\Http\Controllers\GuiController;
4+
5+
\Route::get('/', [GuiController::class, 'index'])
6+
->name('gui.index');
7+
8+
\Route::post('{command}', [GuiController::class, 'run'])
9+
->name('gui.run');

src/Providers/GuiServiceProvider.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Illuminate\Support\ServiceProvider;
88
use Infureal\Http\Controllers\GuiController;
9+
use Infureal\View\Components\Command;
910
use Infureal\View\Components\Group;
1011
use Infureal\View\Components\Header;
1112

@@ -14,7 +15,7 @@ class GuiServiceProvider extends ServiceProvider {
1415

1516
protected $root;
1617
const COMPONENTS = [
17-
\Infureal\View\Components\Command::class,
18+
Command::class,
1819
Header::class,
1920
Group::class,
2021
];
@@ -28,17 +29,13 @@ protected function createRoutes() {
2829
$middleware = ['web'];
2930

3031
if (config('artisan-gui.auth', false))
31-
$middleware += ['auth'];
32+
$middleware[] = 'auth';
3233

3334
\Route::middleware($middleware)
34-
->prefix('artisan')
35+
->prefix(config('artisan-gui.prefix', '~') . 'artisan')
3536
->group(function () {
3637

37-
\Route::get('/', [GuiController::class, 'index'])
38-
->name('gui.index');
39-
40-
\Route::post('{command}', [GuiController::class, 'run'])
41-
->name('gui.run');
38+
$this->loadRoutesFrom("{$this->root}/routes/web.php");
4239

4340
});
4441
}
@@ -60,7 +57,7 @@ function boot() {
6057
// Publish config file [config/artisan-gui.php]
6158
$this->publishes([
6259
"{$this->root}/config/artisan-gui.php" => config_path('artisan-gui.php')
63-
], 'config');
60+
], 'artisan-gui-config');
6461

6562
// Share $__trs variable to views. Just to prevent some repeating
6663
\View::share('__trs', 'transition ease-in-out duration-150');

0 commit comments

Comments
 (0)