mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Updated providers for 5.3
This commit is contained in:
parent
8ca5c6c25e
commit
b83f73f7d6
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
|
@ -13,25 +13,26 @@ class AuthServiceProvider extends ServiceProvider
|
|||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
//'App\Model' => 'App\Policies\ModelPolicy',
|
||||
// We should switch to the below
|
||||
// App\Post::class => PostPolicy::class
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any application authentication / authorization services.
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
|
||||
* @return void
|
||||
*/
|
||||
public function boot(GateContract $gate)
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies($gate);
|
||||
|
||||
//$this->registerPolicies();
|
||||
|
||||
// --------------------------------
|
||||
// BEFORE ANYTHING ELSE
|
||||
// --------------------------------
|
||||
// If this condition is true, ANYTHING else below will be asssumed
|
||||
// to be true. This can cause weird blade behavior.
|
||||
$gate->before(function ($user) {
|
||||
Gate::before(function ($user) {
|
||||
if ($user->isSuperUser()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -41,7 +42,7 @@ class AuthServiceProvider extends ServiceProvider
|
|||
// GENERAL GATES
|
||||
// These control general sections of the admin
|
||||
// --------------------------------
|
||||
$gate->define('admin', function ($user) {
|
||||
Gate::define('admin', function ($user) {
|
||||
if ($user->hasAccess('admin')) {
|
||||
return true;
|
||||
}
|
||||
|
@ -51,7 +52,7 @@ class AuthServiceProvider extends ServiceProvider
|
|||
# -----------------------------------------
|
||||
# Reports
|
||||
# -----------------------------------------
|
||||
$gate->define('reports.view', function ($user) {
|
||||
Gate::define('reports.view', function ($user) {
|
||||
if ($user->hasAccess('reports.view')) {
|
||||
return true;
|
||||
}
|
||||
|
@ -61,44 +62,44 @@ class AuthServiceProvider extends ServiceProvider
|
|||
# -----------------------------------------
|
||||
# Assets
|
||||
# -----------------------------------------
|
||||
$gate->define('assets.view', function ($user) {
|
||||
Gate::define('assets.view', function ($user) {
|
||||
if (($user->hasAccess('assets.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('assets.view.requestable', function ($user) {
|
||||
Gate::define('assets.view.requestable', function ($user) {
|
||||
if (($user->hasAccess('assets.view.requestable')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('assets.create', function ($user) {
|
||||
Gate::define('assets.create', function ($user) {
|
||||
if (($user->hasAccess('assets.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('assets.checkout', function ($user) {
|
||||
Gate::define('assets.checkout', function ($user) {
|
||||
if (($user->hasAccess('assets.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('assets.checkin', function ($user) {
|
||||
Gate::define('assets.checkin', function ($user) {
|
||||
if (($user->hasAccess('assets.checkin')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('assets.edit', function ($user) {
|
||||
Gate::define('assets.edit', function ($user) {
|
||||
if (($user->hasAccess('assets.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Checks for some level of management
|
||||
$gate->define('assets.manage', function ($user) {
|
||||
Gate::define('assets.manage', function ($user) {
|
||||
if (($user->hasAccess('assets.checkin')) || ($user->hasAccess('assets.edit')) || ($user->hasAccess('assets.delete')) || ($user->hasAccess('assets.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -108,44 +109,44 @@ class AuthServiceProvider extends ServiceProvider
|
|||
# -----------------------------------------
|
||||
# Accessories
|
||||
# -----------------------------------------
|
||||
$gate->define('accessories.view', function ($user) {
|
||||
Gate::define('accessories.view', function ($user) {
|
||||
if (($user->hasAccess('accessories.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('accessories.create', function ($user) {
|
||||
Gate::define('accessories.create', function ($user) {
|
||||
if (($user->hasAccess('accessories.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('accessories.edit', function ($user) {
|
||||
Gate::define('accessories.edit', function ($user) {
|
||||
if (($user->hasAccess('accessories.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('accessories.delete', function ($user) {
|
||||
Gate::define('accessories.delete', function ($user) {
|
||||
if (($user->hasAccess('accessories.delete')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('accessories.checkout', function ($user) {
|
||||
Gate::define('accessories.checkout', function ($user) {
|
||||
if (($user->hasAccess('accessories.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('accessories.checkin', function ($user) {
|
||||
Gate::define('accessories.checkin', function ($user) {
|
||||
if (($user->hasAccess('accessories.checkin')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Checks for some level of management
|
||||
$gate->define('accessories.manage', function ($user) {
|
||||
Gate::define('accessories.manage', function ($user) {
|
||||
if (($user->hasAccess('accessories.checkin')) || ($user->hasAccess('accessories.edit')) || ($user->hasAccess('accessories.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -154,44 +155,44 @@ class AuthServiceProvider extends ServiceProvider
|
|||
# -----------------------------------------
|
||||
# Consumables
|
||||
# -----------------------------------------
|
||||
$gate->define('consumables.view', function ($user) {
|
||||
Gate::define('consumables.view', function ($user) {
|
||||
if (($user->hasAccess('consumables.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('consumables.create', function ($user) {
|
||||
Gate::define('consumables.create', function ($user) {
|
||||
if (($user->hasAccess('consumables.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('consumables.edit', function ($user) {
|
||||
Gate::define('consumables.edit', function ($user) {
|
||||
if (($user->hasAccess('consumables.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('consumables.delete', function ($user) {
|
||||
Gate::define('consumables.delete', function ($user) {
|
||||
if (($user->hasAccess('consumables.delete')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('consumables.checkout', function ($user) {
|
||||
Gate::define('consumables.checkout', function ($user) {
|
||||
if (($user->hasAccess('consumables.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('consumables.checkin', function ($user) {
|
||||
Gate::define('consumables.checkin', function ($user) {
|
||||
if (($user->hasAccess('consumables.checkin')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Checks for some level of management
|
||||
$gate->define('consumables.manage', function ($user) {
|
||||
Gate::define('consumables.manage', function ($user) {
|
||||
if (($user->hasAccess('consumables.checkin')) || ($user->hasAccess('consumables.edit')) || ($user->hasAccess('consumables.delete')) || ($user->hasAccess('consumables.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -203,25 +204,25 @@ class AuthServiceProvider extends ServiceProvider
|
|||
# Users
|
||||
# -----------------------------------------
|
||||
|
||||
$gate->define('users.view', function ($user) {
|
||||
Gate::define('users.view', function ($user) {
|
||||
if (($user->hasAccess('users.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('users.create', function ($user) {
|
||||
Gate::define('users.create', function ($user) {
|
||||
if (($user->hasAccess('users.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('users.edit', function ($user) {
|
||||
Gate::define('users.edit', function ($user) {
|
||||
if (($user->hasAccess('users.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('users.delete', function ($user) {
|
||||
Gate::define('users.delete', function ($user) {
|
||||
if (($user->hasAccess('users.delete')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -231,44 +232,38 @@ class AuthServiceProvider extends ServiceProvider
|
|||
# -----------------------------------------
|
||||
# Components
|
||||
# -----------------------------------------
|
||||
$gate->define('components.view', function ($user) {
|
||||
Gate::define('components.view', function ($user) {
|
||||
if (($user->hasAccess('components.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('components.create', function ($user) {
|
||||
Gate::define('components.create', function ($user) {
|
||||
if (($user->hasAccess('components.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('components.edit', function ($user) {
|
||||
Gate::define('components.edit', function ($user) {
|
||||
if (($user->hasAccess('components.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('components.delete', function ($user) {
|
||||
Gate::define('components.delete', function ($user) {
|
||||
if (($user->hasAccess('components.delete')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('components.checkout', function ($user) {
|
||||
if (($user->hasAccess('components.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('components.checkout', function ($user) {
|
||||
Gate::define('components.checkout', function ($user) {
|
||||
if (($user->hasAccess('components.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Checks for some level of management
|
||||
$gate->define('components.manage', function ($user) {
|
||||
Gate::define('components.manage', function ($user) {
|
||||
if (($user->hasAccess('components.edit')) || ($user->hasAccess('components.delete')) || ($user->hasAccess('components.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -278,50 +273,50 @@ class AuthServiceProvider extends ServiceProvider
|
|||
# -----------------------------------------
|
||||
# Licenses
|
||||
# -----------------------------------------
|
||||
$gate->define('licenses.view', function ($user) {
|
||||
Gate::define('licenses.view', function ($user) {
|
||||
if (($user->hasAccess('licenses.view')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.create', function ($user) {
|
||||
Gate::define('licenses.create', function ($user) {
|
||||
if (($user->hasAccess('licenses.create')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.edit', function ($user) {
|
||||
Gate::define('licenses.edit', function ($user) {
|
||||
if (($user->hasAccess('licenses.edit')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.delete', function ($user) {
|
||||
Gate::define('licenses.delete', function ($user) {
|
||||
if (($user->hasAccess('licenses.delete')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.checkout', function ($user) {
|
||||
Gate::define('licenses.checkout', function ($user) {
|
||||
if (($user->hasAccess('licenses.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.checkin', function ($user) {
|
||||
Gate::define('licenses.checkin', function ($user) {
|
||||
if (($user->hasAccess('licenses.checkin')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$gate->define('licenses.keys', function ($user) {
|
||||
Gate::define('licenses.keys', function ($user) {
|
||||
if (($user->hasAccess('licenses.keys')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Checks for some level of management
|
||||
$gate->define('licenses.manage', function ($user) {
|
||||
Gate::define('licenses.manage', function ($user) {
|
||||
if (($user->hasAccess('licenses.checkin')) || ($user->hasAccess('licenses.edit')) || ($user->hasAccess('licenses.delete')) || ($user->hasAccess('licenses.checkout')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -331,12 +326,13 @@ class AuthServiceProvider extends ServiceProvider
|
|||
# -----------------------------------------
|
||||
# Self
|
||||
# -----------------------------------------
|
||||
$gate->define('self.two_factor', function ($user) {
|
||||
Gate::define('self.two_factor', function ($user) {
|
||||
if (($user->hasAccess('self.two_factor')) || ($user->hasAccess('admin'))) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
|
@ -19,14 +19,13 @@ class EventServiceProvider extends ServiceProvider
|
|||
];
|
||||
|
||||
/**
|
||||
* Register any other events for your application.
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @return void
|
||||
*/
|
||||
public function boot(DispatcherContract $events)
|
||||
public function boot()
|
||||
{
|
||||
parent::boot($events);
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to the controller routes in your routes file.
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
|
@ -19,26 +19,61 @@ class RouteServiceProvider extends ServiceProvider
|
|||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
|
||||
parent::boot($router);
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
* @return void
|
||||
*/
|
||||
public function map(Router $router)
|
||||
public function map()
|
||||
{
|
||||
$router->group(['namespace' => $this->namespace], function ($router) {
|
||||
require app_path('Http/routes.php');
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::group([
|
||||
'middleware' => 'web',
|
||||
'namespace' => $this->namespace,
|
||||
], function ($router) {
|
||||
require base_path('routes/web.php');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::group([
|
||||
'middleware' => 'api',
|
||||
'namespace' => $this->namespace,
|
||||
'prefix' => 'api',
|
||||
], function ($router) {
|
||||
require base_path('routes/api.php');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue