Closed xcaptain closed 8 years ago
I think it's a bug, https://github.com/LaravelRUS/SleepingOwlAdmin/blob/development/src/Providers/AdminServiceProvider.php#L65 this line executed before route, so middleware config doesn't work.
Is there any way to get the current user in admin page?
Hi. No. Just i deleted auth
middleware from config
https://github.com/LaravelRUS/SleepingOwlAdmin/commit/29194c4aa07bc9c0a581a0544d3863a8da05f459#diff-ff9838bfdccf5addada05fe70eabfbcfL46
@butschster I added auth middleware to my config, it worked fine and will force redirect to login. but I still can't get current user in app/Admin/Contact.php. \Auth::user()
returns null.
Show me code.
You should add auth
middleware, like this
'middleware' => ['web', 'auth'],
and
AdminSection::registerModel(Post::class, function (ModelConfiguration $model) {
// Display
$model->onDisplay(function () {
dd(auth()->user());
});
})->addMenuPage(Post::class);
Thanks, I found my mistake, I was doing
AdminSection::registerModel(Post::class, function (ModelConfiguration $model) {
// Display
dd(auth()->user());
$model->onDisplay(function () {
});
})->addMenuPage(Post::class);]
so I got null
http://demo.sleepingowladmin.ru/admin/contacts2
This page can be accessed without login, if that's a bug I can help work on it.