mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Merge pull request #828 from joshuadwire/laravel-acl
Don't require new ucwords signature for ACL
This commit is contained in:
commit
bc2880f05e
@ -4,6 +4,7 @@ use App\Http\Middleware\PermissionsRequired;
|
|||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use Utils;
|
||||||
|
|
||||||
class BaseController extends Controller
|
class BaseController extends Controller
|
||||||
{
|
{
|
||||||
@ -34,7 +35,7 @@ class BaseController extends Controller
|
|||||||
$this->authorize('create', $this->entity);
|
$this->authorize('create', $this->entity);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$className = ucwords($this->entity, '_');
|
$className = Utils::getEntityName($this->entity);
|
||||||
|
|
||||||
$object = call_user_func(array("App\\Models\\{$className}", 'scope'), $input['public_id'])->firstOrFail();
|
$object = call_user_func(array("App\\Models\\{$className}", 'scope'), $input['public_id'])->firstOrFail();
|
||||||
$this->authorize('edit', $object);
|
$this->authorize('edit', $object);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Policies;
|
namespace App\Policies;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Utils;
|
||||||
|
|
||||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ class GenericEntityPolicy
|
|||||||
use HandlesAuthorization;
|
use HandlesAuthorization;
|
||||||
|
|
||||||
public static function editByOwner($user, $itemType, $ownerUserId) {
|
public static function editByOwner($user, $itemType, $ownerUserId) {
|
||||||
$itemType = ucwords($itemType, '_');
|
$itemType = Utils::getEntityName($itemType);
|
||||||
if (method_exists("App\\Policies\\{$itemType}Policy", 'editByOwner')) {
|
if (method_exists("App\\Policies\\{$itemType}Policy", 'editByOwner')) {
|
||||||
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'editByOwner'), $user, $ownerUserId);
|
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'editByOwner'), $user, $ownerUserId);
|
||||||
}
|
}
|
||||||
@ -20,7 +21,7 @@ class GenericEntityPolicy
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function viewByOwner($user, $itemType, $ownerUserId) {
|
public static function viewByOwner($user, $itemType, $ownerUserId) {
|
||||||
$itemType = ucwords($itemType, '_');
|
$itemType = Utils::getEntityName($itemType);
|
||||||
if (method_exists("App\\Policies\\{$itemType}Policy", 'viewByOwner')) {
|
if (method_exists("App\\Policies\\{$itemType}Policy", 'viewByOwner')) {
|
||||||
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'viewByOwner'), $user, $ownerUserId);
|
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'viewByOwner'), $user, $ownerUserId);
|
||||||
}
|
}
|
||||||
@ -29,7 +30,7 @@ class GenericEntityPolicy
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function create($user, $itemType) {
|
public static function create($user, $itemType) {
|
||||||
$itemType = ucwords($itemType, '_');
|
$itemType = Utils::getEntityName($itemType);
|
||||||
if (method_exists("App\\Policies\\{$itemType}Policy", 'create')) {
|
if (method_exists("App\\Policies\\{$itemType}Policy", 'create')) {
|
||||||
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'create'), $user);
|
return call_user_func(array("App\\Policies\\{$itemType}Policy", 'create'), $user);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user