Skip to content

Commit

Permalink
Adding new asgard:user:grant-permissions command to grant all module…
Browse files Browse the repository at this point in the history
… permissions to admin role
  • Loading branch information
nWidart committed Oct 10, 2017
1 parent cfa3997 commit 3ae3f77
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Modules/User/Console/GrantRolePermissionsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Modules\User\Console;

use Illuminate\Console\Command;
use Modules\User\Permissions\PermissionsAdder;
use Symfony\Component\Console\Input\InputArgument;

class GrantRolePermissionsCommand extends Command
{
protected $name = 'asgard:user:grant-permissions';
protected $description = 'Grant all the permissions to the admin role of given module';

public function handle()
{
$module = $this->argument('module');

(new PermissionsAdder($module))->addAll();

$this->info("All permissions for [$module] have been added to the admin role");
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [
['module', InputArgument::REQUIRED, 'Module name'],
];
}

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
];
}
}
4 changes: 4 additions & 0 deletions Modules/User/Providers/UserServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\User\Console\GrantRolePermissionsCommand;
use Modules\User\Contracts\Authentication;
use Modules\User\Entities\UserToken;
use Modules\User\Events\Handlers\RegisterUserSidebar;
Expand Down Expand Up @@ -66,6 +67,9 @@ public function register()
BuildingSidebar::class,
$this->getSidebarClassForModule('user', RegisterUserSidebar::class)
);
$this->commands([
GrantRolePermissionsCommand::class,
]);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions Modules/User/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
url: https://github.com/AsgardCms/Platform
versions:
"3.2.0@unreleased":
added:
- Adding new <code>asgard:user:grant-permissions</code> command to grant all module permissions to admin role
"3.1.0":
added:
- Seeding new media.folders permissions on install
Expand Down

0 comments on commit 3ae3f77

Please sign in to comment.