【发布时间】:2016-08-06 14:31:30
【问题描述】:
AuthService 提供者:
public function boot(GateContract $gate)
{
$this->registerPolicies($gate);
$gate->define('show-user', function ($admin) {
return $admin->hasRole('Admin');
});
}
管理员是 Auth Guard
控制器:
public function edit($admin) {
if (Gate::allows('show-user'))
return 'allow';
else {
return 'deny';
}
}
Gate 总是返回“拒绝”
我有一个存储库功能做同样的工作。
public function checkPermission($admin) {
return $this->auth->hasRole('Admin') || $this->auth->id === $admin->id;
}
【问题讨论】:
标签: laravel authentication acl