mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 14:09:43 -08:00
cd8c585377
* Make delete routes work. We put a little form in the modal that spoofs the delete field. * Fix route on creating a user. * Fix redundant id parameter. * Port acceptance tests to new urls. * Initial work on migrating to model based policies instead of global gates. Will allow for much more detailed permissions bits in the future. * This needs to stay for the dashboard checks. * Add user states for permissions to build tests. * Build up unit tests for gates/permissions. Move accessories/consumables/assets to policies instead of in authserviceprovider * Migrate various locations to new syntax. Update test to be more specific * Fix functional tests. Add an artisan command for installing a settings setup on travis-ci * Try a different id... Need to come up with a better way of passing the id for tests that need an existing one. * Try to fix travis * Update urls to use routes and not hardcode old paths. Also fix some migration errors found along the way.: * Add a environment for travis functional tests. * Adjust config file to make travis use it. * Use redirect()->route instead of redirect()-to * Dump all failures in the output directory if travis fails. * Cleanups and minor fixes. * Adjust the supplier modelfactory to comply with new validation restrictions. * Some test fixes. * Locales can be longer than 5 characters according to faker... fex gez_ET. Increase lenght in mysql and add a validation * Update test database dump to latest migrations.
87 lines
2.5 KiB
PHP
87 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Accessory;
|
|
use App\Models\Asset;
|
|
use App\Models\Component;
|
|
use App\Models\Consumable;
|
|
use App\Models\License;
|
|
use App\Models\User;
|
|
use App\Policies\AccessoryPolicy;
|
|
use App\Policies\AssetPolicy;
|
|
use App\Policies\ComponentPolicy;
|
|
use App\Policies\ConsumablePolicy;
|
|
use App\Policies\LicensePolicy;
|
|
use App\Policies\UserPolicy;
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Laravel\Passport\Passport;
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* The policy mappings for the application.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $policies = [
|
|
Asset::class => AssetPolicy::class,
|
|
Accessory::class => AccessoryPolicy::class,
|
|
Component::class => ComponentPolicy::class,
|
|
Consumable::class => ConsumablePolicy::class,
|
|
License::class => LicensePolicy::class,
|
|
User::class => UserPolicy::class,
|
|
];
|
|
|
|
/**
|
|
* Register any authentication / authorization services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
$this->registerPolicies();
|
|
Passport::routes();
|
|
// --------------------------------
|
|
// 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) {
|
|
if ($user->isSuperUser()) {
|
|
return true;
|
|
}
|
|
});
|
|
|
|
// --------------------------------
|
|
// GENERAL GATES
|
|
// These control general sections of the admin
|
|
// --------------------------------
|
|
Gate::define('admin', function ($user) {
|
|
if ($user->hasAccess('admin')) {
|
|
return true;
|
|
}
|
|
});
|
|
|
|
|
|
# -----------------------------------------
|
|
# Reports
|
|
# -----------------------------------------
|
|
Gate::define('reports.view', function ($user) {
|
|
if ($user->hasAccess('reports.view')) {
|
|
return true;
|
|
}
|
|
});
|
|
|
|
# -----------------------------------------
|
|
# Self
|
|
# -----------------------------------------
|
|
Gate::define('self.two_factor', function ($user) {
|
|
if (($user->hasAccess('self.two_factor')) || ($user->hasAccess('admin'))) {
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
}
|