|
1
|
|
|
<?php namespace Arcanesoft\Foundation\Providers; |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Contracts\Auth\Access\Gate as GateContract; |
|
4
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class AuthorizationServiceProvider |
|
8
|
|
|
* |
|
9
|
|
|
* @package Arcanesoft\Foundation\Providers |
|
10
|
|
|
* @author ARCANEDEV <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class AuthorizationServiceProvider extends ServiceProvider |
|
13
|
|
|
{ |
|
14
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
15
|
|
|
| Properties |
|
16
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
17
|
|
|
*/ |
|
18
|
|
|
/** |
|
19
|
|
|
* The policy mappings for the application. |
|
20
|
|
|
* |
|
21
|
|
|
* @var array |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $policies = [ |
|
24
|
|
|
// |
|
25
|
|
|
]; |
|
26
|
|
|
|
|
27
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
28
|
|
|
| Main Functions |
|
29
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
30
|
|
|
*/ |
|
31
|
|
|
/** |
|
32
|
|
|
* Register any application authentication / authorization services. |
|
33
|
|
|
* |
|
34
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
|
35
|
|
|
*/ |
|
36
|
24 |
|
public function boot(GateContract $gate) |
|
37
|
|
|
{ |
|
38
|
24 |
|
$this->registerPolicies($gate); |
|
39
|
|
|
|
|
40
|
|
|
/** @var \Illuminate\Auth\Access\Gate $gate */ |
|
41
|
|
|
$gate->before(function ($user, $ability) { |
|
|
|
|
|
|
42
|
|
|
/** @var \Arcanesoft\Auth\Models\User $user */ |
|
43
|
|
|
return $user->isAdmin() ? true : null; |
|
44
|
24 |
|
}); |
|
45
|
|
|
|
|
46
|
24 |
|
$this->registerLogViewerPolicies($gate); |
|
47
|
24 |
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Register LogViewer policies. |
|
51
|
|
|
* |
|
52
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
|
53
|
|
|
*/ |
|
54
|
24 |
|
private function registerLogViewerPolicies(GateContract $gate) |
|
55
|
|
|
{ |
|
56
|
|
|
// TODO: Complete the log-viewer policy implementations. |
|
57
|
|
|
$gate->define('foundation::log-viewer.dashboard', function ($user) { |
|
|
|
|
|
|
58
|
|
|
return true; |
|
59
|
24 |
|
}); |
|
60
|
|
|
|
|
61
|
|
|
$gate->define('foundation::log-viewer.list', function ($user) { |
|
|
|
|
|
|
62
|
|
|
return true; |
|
63
|
24 |
|
}); |
|
64
|
|
|
|
|
65
|
|
|
$gate->define('foundation::log-viewer.show', function ($user) { |
|
|
|
|
|
|
66
|
|
|
return true; |
|
67
|
24 |
|
}); |
|
68
|
|
|
|
|
69
|
|
|
$gate->define('foundation::log-viewer.download', function ($user) { |
|
|
|
|
|
|
70
|
|
|
return true; |
|
71
|
24 |
|
}); |
|
72
|
|
|
|
|
73
|
24 |
|
$gate->define('foundation::log-viewer.delete', function ($user) { |
|
|
|
|
|
|
74
|
|
|
return true; |
|
75
|
24 |
|
}); |
|
76
|
24 |
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.