mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Refactored some core entity actions
- Created BookChild class to share some page/chapter logic. - Gave entities the power to generate their own permissions and slugs. - Moved bits out of BaseController constructor since it was overly sticky. - Moved slug generation logic into its own class. - Created a facade for permissions due to high use. - Fixed failing test issues from last commits
This commit is contained in:
@ -2,9 +2,6 @@
|
||||
|
||||
namespace BookStack\Http\Controllers;
|
||||
|
||||
use BookStack\Auth\User;
|
||||
use BookStack\Entities\Entity;
|
||||
use BookStack\Facades\Activity;
|
||||
use BookStack\Ownable;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
@ -16,23 +13,20 @@ abstract class Controller extends BaseController
|
||||
{
|
||||
use DispatchesJobs, ValidatesRequests;
|
||||
|
||||
/**
|
||||
* @var User static
|
||||
*/
|
||||
protected $currentUser;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $signedIn;
|
||||
|
||||
/**
|
||||
* Controller constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->currentUser = user();
|
||||
$this->signedIn = auth()->check();
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user is signed in.
|
||||
*/
|
||||
protected function isSignedIn(): bool
|
||||
{
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,7 +117,7 @@ abstract class Controller extends BaseController
|
||||
protected function checkPermissionOrCurrentUser(string $permissionName, int $userId)
|
||||
{
|
||||
return $this->checkPermissionOr($permissionName, function () use ($userId) {
|
||||
return $userId === $this->currentUser->id;
|
||||
return $userId === user()->id;
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user