Skip to content

Commit

Permalink
Merge pull request #22 from MrCrayon/check-permission
Browse files Browse the repository at this point in the history
Check browse_hooks permission
  • Loading branch information
marktopper authored Apr 18, 2018
2 parents 60ef817 + c5e54d0 commit 627eae2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Controllers/HooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Larapack\Hooks\Hooks;
use TCG\Voyager\Facades\Voyager;

class HooksController extends Controller
{
Expand All @@ -20,6 +21,9 @@ public function __construct(Hooks $hooks, Request $request)

public function index()
{
// Check permission
Voyager::canOrFail('browse_hooks');

$lastUpdated = $this->hooks->getLastRemoteCheck();

if (is_null($lastUpdated)) {
Expand All @@ -36,6 +40,9 @@ public function index()

public function install()
{
// Check permission
Voyager::canOrFail('browse_hooks');

$name = $this->request->get('name');
$this->hooks->install($name);

Expand All @@ -44,27 +51,39 @@ public function install()

public function uninstall($name)
{
// Check permission
Voyager::canOrFail('browse_hooks');

$this->hooks->uninstall($name);

return $this->redirect("Hook [{$name}] have been uninstalled!");
}

public function update($name)
{
// Check permission
Voyager::canOrFail('browse_hooks');

$this->hooks->update($name);

return $this->redirect("Hook [{$name}] have been updated!");
}

public function enable($name)
{
// Check permission
Voyager::canOrFail('browse_hooks');

$this->hooks->enable($name);

return $this->redirect("Hook [{$name}] have been enabled!");
}

public function disable($name)
{
// Check permission
Voyager::canOrFail('browse_hooks');

$this->hooks->disable($name);

return $this->redirect("Hook [{$name}] have been disabled!");
Expand Down

0 comments on commit 627eae2

Please sign in to comment.