Skip to content

Commit

Permalink
Adding new asgard:user:remove-permissions command to remove all permi…
Browse files Browse the repository at this point in the history
…ssions of given module from roles and users
  • Loading branch information
nWidart committed Oct 10, 2017
1 parent 1321a74 commit 84e19ce
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Modules/User/Console/RemoveModulePermissionsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Modules\User\Console;

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

class RemoveModulePermissionsCommand extends Command
{
protected $name = 'asgard:user:remove-permissions';
protected $description = 'Remove all the permissions for given module from any role or user';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$module = $this->argument('module');

(new PermissionsRemover($module))->removeAll();

$this->info("All permissions for [$module] have been removed");
}

/**
* 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 [
];
}
}
2 changes: 2 additions & 0 deletions Modules/User/Providers/UserServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\User\Console\GrantModulePermissionsCommand;
use Modules\User\Console\RemoveModulePermissionsCommand;
use Modules\User\Contracts\Authentication;
use Modules\User\Entities\UserToken;
use Modules\User\Events\Handlers\RegisterUserSidebar;
Expand Down Expand Up @@ -69,6 +70,7 @@ public function register()
);
$this->commands([
GrantModulePermissionsCommand::class,
RemoveModulePermissionsCommand::class,
]);
}

Expand Down
1 change: 1 addition & 0 deletions Modules/User/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ versions:
"3.2.0@unreleased":
added:
- Adding new <code>asgard:user:grant-permissions</code> command to grant all module permissions to admin role
- Adding new <code>asgard:user:remove-permissions</code> command to remove all permissions of given module from roles and users
"3.1.0":
added:
- Seeding new media.folders permissions on install
Expand Down

0 comments on commit 84e19ce

Please sign in to comment.