添加sudo包及部分权限管理
This commit is contained in:
parent
6ff802ec80
commit
1a547d8d07
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Policies;
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||||
|
|
||||||
class Policy
|
class Policy
|
||||||
|
@ -13,10 +14,10 @@ class Policy
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
public function before($user, $ability)
|
public function before(User $user, $ability)
|
||||||
{
|
{
|
||||||
// if ($user->isSuperAdmin()) {
|
if ($user->can('manage_contents')) {
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,5 +34,8 @@ class AppServiceProvider extends ServiceProvider
|
||||||
if ($this->app->environment() !== 'production') {
|
if ($this->app->environment() !== 'production') {
|
||||||
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
||||||
}
|
}
|
||||||
|
if (app()->isLocal()) {
|
||||||
|
$this->app->register(\VIACreative\SudoSu\ServiceProvider::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Providers;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Policies\UserPolicy;
|
use App\Policies\UserPolicy;
|
||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
use Laravel\Horizon\Horizon;
|
||||||
|
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -28,7 +29,9 @@ class AuthServiceProvider extends ServiceProvider
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->registerPolicies();
|
$this->registerPolicies();
|
||||||
|
Horizon::auth(function ($request) {
|
||||||
|
return \Auth::user()->hasRole('Founder');
|
||||||
|
});
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
"overtrue/laravel-lang": "^3.0",
|
"overtrue/laravel-lang": "^3.0",
|
||||||
"overtrue/pinyin": "~3.0",
|
"overtrue/pinyin": "~3.0",
|
||||||
"predis/predis": "~1.0",
|
"predis/predis": "~1.0",
|
||||||
"spatie/laravel-permission": "~2.7"
|
"spatie/laravel-permission": "~2.7",
|
||||||
|
"viacreative/sudo-su": "~1.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"barryvdh/laravel-debugbar": "^3.1",
|
"barryvdh/laravel-debugbar": "^3.1",
|
||||||
|
|
456
composer.lock
generated
456
composer.lock
generated
File diff suppressed because it is too large
Load Diff
32
config/sudosu.php
Normal file
32
config/sudosu.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Allowed TLDs - Use with caution!
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This is to prevent mis-usage during production if debug mode is
|
||||||
|
| unintentionally left active. The package will detect the site
|
||||||
|
| URL and if the TLD isn't present in this array, it will not
|
||||||
|
| activate. If your development TLD is different to .dev or
|
||||||
|
| .local, simply add it to the arrow below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'allowed_tlds' => ['dev', 'local', 'test'],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| User Model
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Path to the application User model. This will be used to retrieve the users
|
||||||
|
| displayed in the select dropdown. This must be an Eloquent Model instance.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'user_model' => \App\Models\User::class
|
||||||
|
|
||||||
|
];
|
68
public/sudo-su/css/app.css
vendored
Normal file
68
public/sudo-su/css/app.css
vendored
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
.sudoSu {
|
||||||
|
position: fixed;
|
||||||
|
right: 30px;
|
||||||
|
bottom: 30px;
|
||||||
|
z-index: 99999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sudoSu__btn {
|
||||||
|
font-size: 1.5em;
|
||||||
|
background: #333;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sudoSu__btn--hasSudoed {
|
||||||
|
background: #00b067;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sudoSu__interface {
|
||||||
|
position: absolute;
|
||||||
|
right: 60px;
|
||||||
|
bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sudoSu__interface--hasSudoed {
|
||||||
|
background: white;
|
||||||
|
padding: 20px;
|
||||||
|
bottom: 0;
|
||||||
|
border: 1px solid #cecece;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
|
||||||
|
width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sudoSu__infoLine {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sudoSu__infoLine > span {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sudoSu__resetBtn {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
cursor: pointer;
|
||||||
|
border: 0;
|
||||||
|
margin: 5px 0 15px 0;
|
||||||
|
padding: 6px 10px;
|
||||||
|
background: #00b067;
|
||||||
|
color: white;
|
||||||
|
border-radius: 4px;
|
||||||
|
border-bottom: 2px solid #088b54;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sudoSu__resetBtn:hover {
|
||||||
|
background: #088b54;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJlc291cmNlcy9hc3NldHMvc2Fzcy9hcHAuc2NzcyJdLCJzb3VyY2VzQ29udGVudCI6WyIuc3Vkb1N1IHtcbiAgICBwb3NpdGlvbjogZml4ZWQ7XG4gICAgcmlnaHQ6IDMwcHg7XG4gICAgYm90dG9tOiAzMHB4O1xuICAgIHotaW5kZXg6IDk5OTk5O1xuXG4gICAgJl9fYnRuIHtcbiAgICAgICAgZm9udC1zaXplOiAxLjVlbTtcbiAgICAgICAgYmFja2dyb3VuZDogIzMzMztcbiAgICAgICAgd2lkdGg6IDQwcHg7XG4gICAgICAgIGhlaWdodDogNDBweDtcbiAgICAgICAgbGluZS1oZWlnaHQ6IDQwcHg7XG4gICAgICAgIGNvbG9yOiB3aGl0ZTtcbiAgICAgICAgdGV4dC1hbGlnbjogY2VudGVyO1xuICAgICAgICBib3JkZXItcmFkaXVzOiA1MCU7XG5cbiAgICAgICAgJi0taGFzU3Vkb2VkIHtcbiAgICAgICAgICAgIGJhY2tncm91bmQ6ICMwMGIwNjc7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICAmX19pbnRlcmZhY2Uge1xuICAgICAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgICAgIHJpZ2h0OiA2MHB4O1xuICAgICAgICBib3R0b206IDhweDtcblxuICAgICAgICAmLS1oYXNTdWRvZWQge1xuICAgICAgICAgICAgYmFja2dyb3VuZDogd2hpdGU7XG4gICAgICAgICAgICBwYWRkaW5nOiAyMHB4O1xuICAgICAgICAgICAgYm90dG9tOiAw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PQUFPLEVBQUUsUUFBUTtFQUNqQixVQUFVLEVBQUUsT0FBTztFQUNuQixLQUFLLEVBQUUsS0FBSztFQUNaLGFBQWEsRUFBRSxHQUFHO0VBQ2xCLGFBQWEsRUFBRSxpQkFBaUI7Q0FLbkM7O0FBZkQsQUFZSSxpQkFaTyxBQVlQLE1BQU8sQ0FBQztFQUNKLFVBQVUsRUFBRSxPQUFPO0NBQ3RCOztBQUlULEFBQUEsT0FBTyxDQUFDO0VBQ0osT0FBTyxFQUFFLElBQUk7Q0FDaEIifQ== */
|
|
@ -31,6 +31,9 @@
|
||||||
|
|
||||||
@include('layouts._footer')
|
@include('layouts._footer')
|
||||||
</div>
|
</div>
|
||||||
|
@if(app()->isLocal())
|
||||||
|
@include('sudosu::user-selector')
|
||||||
|
@endif
|
||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script src="{{ asset('js/app.js') }}"></script>
|
<script src="{{ asset('js/app.js') }}"></script>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user