Aug 5, 2022
4
Level 5
make telescope open for only admins
I installed telescope from the Laravel docs and I need to make it open only for admins
I have multi-guard auth:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
],
I follow this repo ( https://github.com/laravel/telescope/issues/294 ) and try all solutions there but not a single one works for me!
the final one is in TelescopeServiceProvider :
protected function authorization()
{
Auth::setDefaultDriver('admin');
parent::authorization();
}
Clear cache but still everyone can access :(
Level 5
I solve the problem like this in TelescopeServiceProvider:
protected function gate()
{
Gate::define('viewTelescope', function ($user) {
return true;
});
}
protected function authorization()
{
Auth::setDefaultDriver('admin');
parent::authorization();
}
And to check the authorization works you have to change APP_ENV to production in local otherwise will always open.
@sinnbeck Thanks
1 like
Please or to participate in this conversation.