v0.10.15h - Fixed admin access

This commit is contained in:
frederikpyt 2020-08-27 10:59:19 +02:00
parent 5766770a4b
commit c0669d6eda
2 changed files with 12 additions and 5 deletions

View File

@ -3,9 +3,7 @@
namespace App\Helpers;
use Illuminate\Support\Facades\Auth;
use Jenssegers\Agent\Agent;
class Detector
@ -16,7 +14,11 @@ class Detector
if($agent->isMobile()) {
return view(config("detector.mobilePath") . "." . $viewName, $args);
} else if(Auth()->user() !== null) {
if (Auth()->user()->can('admin.panel.show') == true)
return view(config("detector.defaultPath") . "." . $viewName, $args);
}
return view(config("detector.defaultPath") . "." . $viewName, $args);
return view(config("detector.mobilePath") . "." . $viewName, $args);
}
}

View File

@ -3,6 +3,7 @@
namespace App\Providers;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\ServiceProvider;
use Jenssegers\Agent\Facades\Agent;
@ -28,8 +29,12 @@ class DetectorServiceProvider extends ServiceProvider
Response::macro("detect", function ($view, $args = []) {
if(Agent::isMobile()) {
return view(config("detector.mobilePath") . "." . $view, $args);
} else if(Auth()->user() !== null){
if(Auth()->user()->can('admin.panel.show') == true)
return view(config("detector.defaultPath") . "." . $view, $args);
}
return view(config("detector.defaultPath") . "." . $view, $args);
return view(config("detector.mobilePath") . "." . $view, $args);
});
}
}