Skip to content

Commit 58f573a

Browse files
committed
IMPROVEMENTS
Added before backend access hook
1 parent b9a1c33 commit 58f573a

File tree

7 files changed

+32
-0
lines changed

7 files changed

+32
-0
lines changed

src/Darryldecode/Backend/Base/Controllers/BaseController.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,17 @@ public function __construct()
2323
$this->app = $app;
2424
$this->user = $app['auth']->user();
2525
}
26+
27+
/**
28+
* The before backend access hook
29+
*/
30+
public function triggerBeforeBackendHook()
31+
{
32+
$hook = config('backend.backend.before_backend_access');
33+
34+
if( is_callable($hook) )
35+
{
36+
$hook($this->user);
37+
}
38+
}
2639
}

src/Darryldecode/Backend/Components/Dashboard/Controllers/DashboardController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function __construct()
2020
{
2121
parent::__construct();
2222
$this->middleware('backend.authenticated');
23+
$this->triggerBeforeBackendHook();
2324
}
2425

2526
/**

src/Darryldecode/Backend/Components/MediaManager/Controllers/MediaManagerController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public function ls()
5858
}
5959
else
6060
{
61+
$this->triggerBeforeBackendHook();
62+
6163
return view('mediaManager::mediaManager');
6264
}
6365
}

src/Darryldecode/Backend/Components/Navigation/Controllers/NavigationController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public function getNavBuilderDisplay()
7474
}
7575
else
7676
{
77+
$this->triggerBeforeBackendHook();
78+
7779
return view('navigationBuilder::navigation-builder');
7880
}
7981
}

src/Darryldecode/Backend/Components/User/Controllers/GroupController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public function index()
6161
}
6262
else
6363
{
64+
$this->triggerBeforeBackendHook();
65+
6466
return view('userManager::groups', compact('results'));
6567
}
6668
}

src/Darryldecode/Backend/Components/User/Controllers/UserController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public function index()
6666
}
6767
else
6868
{
69+
$this->triggerBeforeBackendHook();
70+
6971
return view('userManager::users', compact('result'));
7072
}
7173
}

src/Darryldecode/Backend/Config/backend.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,14 @@
4343
*/
4444
'user_model' => 'Darryldecode\Backend\Components\User\Models\User',
4545
'content_model' => 'Darryldecode\Backend\Components\ContentBuilder\Models\Content',
46+
47+
/*
48+
* Before Backend Access Hook
49+
*
50+
* Here you can check if user is in groups or has permissions to redirect to any route
51+
* you want when it does not matches your criteria to access the backend
52+
*/
53+
'before_backend_access' => function($user) {
54+
55+
}
4656
];

0 commit comments

Comments
 (0)