X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a14b5c33fde770ce6b142f9e5535b4caffcdf121..refs/pull/84/head:/app/Http/Controllers/Controller.php diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 4182743a7..f0cb47cd9 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -68,7 +68,7 @@ abstract class Controller extends BaseController protected function showPermissionError() { Session::flash('error', trans('errors.permission')); - $response = request()->wantsJson() ? response()->json(['error' => trans('errors.permissionJson')], 403) : redirect('/', 403); + $response = request()->wantsJson() ? response()->json(['error' => trans('errors.permissionJson')], 403) : redirect('/'); throw new HttpResponseException($response); } @@ -93,10 +93,8 @@ abstract class Controller extends BaseController */ protected function checkOwnablePermission($permission, Ownable $ownable) { - $permissionBaseName = strtolower($permission) . '-'; - if (userCan($permissionBaseName . 'all')) return true; - if (userCan($permissionBaseName . 'own') && $ownable->createdBy->id === $this->currentUser->id) return true; - $this->showPermissionError(); + if (userCan($permission, $ownable)) return true; + return $this->showPermissionError(); } /**