Skip to content

Commit

Permalink
Fix bug [not applying 'auth' middleware]. Add [~] prefix to routes
Browse files Browse the repository at this point in the history
  • Loading branch information
infureal committed Nov 4, 2020
1 parent c69a398 commit 55483e6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ php artisan vendor:publish --provider="Infureal\Providers\GuiServiceProvider"
## Running command
By default, you can access this page only when in local environment.

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

## Issues
Expand Down
3 changes: 3 additions & 0 deletions config/artisan-gui.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// Show commands only when authenticated
'auth' => true,

// route prefix -> ~artisan
'prefix' => '~',

// Register routes only when local environment
'only_local' => true,

Expand Down
9 changes: 9 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use Infureal\Http\Controllers\GuiController;

\Route::get('/', [GuiController::class, 'index'])
->name('gui.index');

\Route::post('{command}', [GuiController::class, 'run'])
->name('gui.run');
15 changes: 6 additions & 9 deletions src/Providers/GuiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Illuminate\Support\ServiceProvider;
use Infureal\Http\Controllers\GuiController;
use Infureal\View\Components\Command;
use Infureal\View\Components\Group;
use Infureal\View\Components\Header;

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

protected $root;
const COMPONENTS = [
\Infureal\View\Components\Command::class,
Command::class,
Header::class,
Group::class,
];
Expand All @@ -28,17 +29,13 @@ protected function createRoutes() {
$middleware = ['web'];

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

\Route::middleware($middleware)
->prefix('artisan')
->prefix(config('artisan-gui.prefix', '~') . 'artisan')
->group(function () {

\Route::get('/', [GuiController::class, 'index'])
->name('gui.index');

\Route::post('{command}', [GuiController::class, 'run'])
->name('gui.run');
$this->loadRoutesFrom("{$this->root}/routes/web.php");

});
}
Expand All @@ -60,7 +57,7 @@ function boot() {
// Publish config file [config/artisan-gui.php]
$this->publishes([
"{$this->root}/config/artisan-gui.php" => config_path('artisan-gui.php')
], 'config');
], 'artisan-gui-config');

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

0 comments on commit 55483e6

Please sign in to comment.