Skip to content

Commit 2030ac8

Browse files
author
Bryan Smit
committed
Modify functionality of adding middleware
1 parent 88278a4 commit 2030ac8

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Plugin.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
namespace Vdlp\BasicAuthentication;
66

77
use Backend\Helpers\Backend as BackendHelper;
8+
use Illuminate\Routing\Router;
89
use October\Rain\Foundation\Application;
9-
use October\Rain\Foundation\Http\Kernel;
1010
use System\Classes\PluginBase;
1111
use Vdlp\BasicAuthentication\Console\CreateCredentialsCommand;
1212
use Vdlp\BasicAuthentication\Http\Middleware\BasicAuthenticationMiddleware;
@@ -40,14 +40,13 @@ public function boot(): void
4040
(bool) config('basicauthentication.enabled', false) === false
4141
|| $application->runningInConsole()
4242
|| $application->runningUnitTests()
43-
|| $application->runningInBackend()
4443
) {
4544
return;
4645
}
4746

48-
/** @var Kernel $kernel */
49-
$kernel = $application['Illuminate\Contracts\Http\Kernel'];
50-
$kernel->prependMiddleware(BasicAuthenticationMiddleware::class);
47+
/** @var Router $router */
48+
$router = $application->make(Router::class);
49+
$router->pushMiddlewareToGroup('web', BasicAuthenticationMiddleware::class);
5150
}
5251

5352
public function registerPermissions(): array

0 commit comments

Comments
 (0)