-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Bug] web_middleware list causes errors #3094
Comments
Hello there! Thanks for opening your first issue on this repo! Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that. Backpack communication channels:
Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch. Thank you! -- |
Hi @hirakujira I think you have an outdated config file. The current config files goes like this: https://github.com/Laravel-Backpack/CRUD/blob/master/src/config/backpack/base.php // The classes for the middleware to check if the visitor is an admin
// Can be a single class or an array of clases
'middleware_class' => [
App\Http\Middleware\CheckIfAdmin::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
// \Backpack\CRUD\app\Http\Middleware\UseBackpackAuthGuardInsteadOfDefaultAuthGuard::class,
],
// Alias for that middleware
'middleware_key' => 'admin',
// Note: It's recommended to use the backpack_middleware() helper everywhere, which pulls this key for you. I don't think there is a bug here. If I am wrong please re-open. Best, |
Thanks for your explanation, @pxpm ! However when I check the code, I still feel confused. In https://github.com/Laravel-Backpack/CRUD/blob/master/src/config/backpack/base.php, there are two middleware groups, one is As you can see, in https://github.com/Laravel-Backpack/CRUD/blob/master/src/routes/backpack/custom.php, the route loads both So the problem is that your solution is for the CRUD/src/config/backpack/base.php Lines 178 to 222 in d9e6201
|
Bug report
What I did
I followed the instruction in:
CRUD/src/config/backpack/base.php
Lines 181 to 189 in 91a8093
I commented
'web_middleware' => 'web',
and use the list below itWhat I expected to happen
Backpack load the middlewares in the list
What happened
It shows
Illegal offset type in isset or empty
error.What I've already tried to fix it
I think it's because when Backpack loads middleware
CRUD/src/routes/backpack/custom.php
Lines 9 to 14 in 91a8093
If I use custom
web_middleware
list, the middleware would be like this:As you can see, it's an array in another array, which causes this bug.
Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:PHP VERSION:
PHP 7.4.5 (cli) (built: Apr 17 2020 12:02:59) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.5, Copyright (c), by Zend Technologies
LARAVEL VERSION:
v7.22.4@30e851a2b3a2af73fba0b7f4fa22b04260db98e7
BACKPACK VERSION:
4.1.15@6c751de946a9c8511dd32eb7bfa3ca6a568849f5
The text was updated successfully, but these errors were encountered: