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

52 lines
1.2 KiB
PHP
Raw Normal View History

2018-10-04 19:10:43 +02:00
<?php
namespace App\Providers;
use App\Models\Client;
use App\Policies\ClientPolicy;
use Auth;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
2018-10-04 19:10:43 +02:00
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
Client::class => ClientPolicy::class,
2018-10-04 19:10:43 +02:00
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
2018-10-04 19:10:43 +02:00
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();
});
}
2018-10-04 19:10:43 +02:00
}