Skip to content

Commit

Permalink
Add manage contents permission and visit horizon dashboard permission
Browse files Browse the repository at this point in the history
  • Loading branch information
hackjie committed Jul 19, 2018
1 parent 27ffb18 commit e77d246
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 7 deletions.
7 changes: 4 additions & 3 deletions app/Policies/Policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ public function __construct()

public function before($user, $ability)
{
// if ($user->isSuperAdmin()) {
// return true;
// }
// 如果用户拥有管理内容的权限的话,即授权通过
if ($user->can('manage_contents')) {
return true;
}
}
}
5 changes: 4 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function boot()
*/
public function register()
{
//
// 用户切换工具 sudo-su
if (app()->isLocal()) {
$this->app->register(\VIACreative\SudoSu\ServiceProvider::class);
}
}
}
5 changes: 4 additions & 1 deletion app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function boot()
{
$this->registerPolicies();

//
\Horizon::auth(function ($request) {
// 是否是站长
return \Auth::user()->hasRole('Founder');
});
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"overtrue/laravel-lang": "~3.0",
"overtrue/pinyin": "~3.0",
"predis/predis": "~1.0",
"spatie/laravel-permission": "~2.7"
"spatie/laravel-permission": "~2.7",
"viacreative/sudo-su": "~1.1"
},
"require-dev": {
"barryvdh/laravel-debugbar": "~3.1",
Expand Down
42 changes: 41 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions config/sudosu.php
Original file line number Diff line number Diff line change
@@ -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 changes: 68 additions & 0 deletions public/sudo-su/css/app.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
@include('layouts._footer')
</div>

<!-- 用户切换工具 sudo-su 植入 -->
@if (app()->isLocal())
@include('sudosu::user-selector')
@endif

<!-- Scripts -->
<script src="{{ asset('js/app.js') }}"></script>
@yield('scripts')
Expand Down

0 comments on commit e77d246

Please sign in to comment.