Skip to content

Commit

Permalink
站点权限部署
Browse files Browse the repository at this point in the history
  • Loading branch information
summerblue committed Sep 20, 2019
1 parent 2125513 commit aedb319
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 12 deletions.
14 changes: 5 additions & 9 deletions app/Policies/Policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ class Policy
{
use HandlesAuthorization;

public function __construct()
public function before($user, $ability)
{
//
// 如果用户拥有管理内容的权限的话,即授权通过
if ($user->can('manage_contents')) {
return true;
}
}

public function before($user, $ability)
{
// if ($user->isSuperAdmin()) {
// return true;
// }
}
}
4 changes: 3 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
//
if (app()->isLocal()) {
$this->app->register(\VIACreative\SudoSu\ServiceProvider::class);
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ public function boot()
// 动态返回模型对应的策略名称,如:// 'App\Model\User' => 'App\Policies\UserPolicy',
return 'App\Policies\\'.class_basename($modelClass).'Policy';
});

\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 @@ -21,7 +21,8 @@
"overtrue/pinyin": "~4.0",
"predis/predis": "~1.1",
"spatie/laravel-permission": "~3.0",
"summerblue/laravel-active": "6.*"
"summerblue/laravel-active": "6.*",
"viacreative/sudo-su": "~1.1"
},
"require-dev": {
"barryvdh/laravel-debugbar": "~3.2",
Expand Down
48 changes: 47 additions & 1 deletion composer.lock

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

10 changes: 10 additions & 0 deletions config/sudosu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

return [

// 允许使用的顶级域名
'allowed_tlds' => ['dev', 'local', 'test'],

// 用户模型
'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.

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

@if (app()->isLocal())
@include('sudosu::user-selector')
@endif

<!-- Scripts -->
<script src="{{ mix('js/app.js') }}"></script>

Expand Down

0 comments on commit aedb319

Please sign in to comment.