X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/2385a6c29b7b9c03123def135d3c6e95febaf9dd..refs/pull/3391/head:/app/Console/Commands/RegeneratePermissions.php diff --git a/app/Console/Commands/RegeneratePermissions.php b/app/Console/Commands/RegeneratePermissions.php index 966ee4a82..4fde08e6b 100644 --- a/app/Console/Commands/RegeneratePermissions.php +++ b/app/Console/Commands/RegeneratePermissions.php @@ -2,7 +2,7 @@ namespace BookStack\Console\Commands; -use BookStack\Services\PermissionService; +use BookStack\Auth\Permissions\PermissionService; use Illuminate\Console\Command; class RegeneratePermissions extends Command @@ -12,7 +12,7 @@ class RegeneratePermissions extends Command * * @var string */ - protected $signature = 'bookstack:regenerate-permissions'; + protected $signature = 'bookstack:regenerate-permissions {--database= : The database connection to use.}'; /** * The console command description. @@ -30,8 +30,6 @@ class RegeneratePermissions extends Command /** * Create a new command instance. - * - * @param PermissionService $permissionService */ public function __construct(PermissionService $permissionService) { @@ -46,7 +44,15 @@ class RegeneratePermissions extends Command */ public function handle() { + $connection = \DB::getDefaultConnection(); + if ($this->option('database') !== null) { + \DB::setDefaultConnection($this->option('database')); + $this->permissionService->setConnection(\DB::connection($this->option('database'))); + } + $this->permissionService->buildJointPermissions(); + + \DB::setDefaultConnection($connection); $this->comment('Permissions regenerated'); } }