1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Providers/AuthServiceProvider.php
2019-05-02 21:07:38 +10:00

63 lines
1.5 KiB
PHP

<?php
namespace App\Providers;
use App\Models\Client;
use App\Models\Invoice;
use App\Models\Product;
use App\Models\Quote;
use App\Models\User;
use App\Policies\ClientPolicy;
use App\Policies\InvoicePolicy;
use App\Policies\ProductPolicy;
use App\Policies\QuotePolicy;
use Auth;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
Client::class => ClientPolicy::class,
Product::class => ProductPolicy::class,
Invoice::class => InvoicePolicy::class,
Quote::class => QuotePolicy::class,
User::class => UserPolicy::class,
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
Auth::provider('users', function ($app, array $config) {
return new MultiDatabaseUserProvider($this->app['hash'], $config['model']);
});
Auth::provider('contacts', function ($app, array $config) {
return new MultiDatabaseUserProvider($this->app['hash'], $config['model']);
});
Gate::define('view-list', function ($user, $entity) {
$entity = strtolower(class_basename($entity));
return $user->hasPermission('view_' . $entity) || $user->isAdmin();
});
}
}