Commit 4c45c22e authored by Nicolas Widart's avatar Nicolas Widart

Pointing the filter class in the core module

parent c548bcec
<?php namespace Modules\User\Http\Filters;
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
use Laracasts\Flash\Flash;
class PermissionFilter
{
public function filter($route, $request)
{
$action = $route->getActionName();
$actionMethod = substr($action, strpos($action, "@") + 1);
if (Sentinel::hasAccess("{$request->segment(2)}.$actionMethod"))
{
return;
}
Flash::error('Permission denied.');
return Redirect::to('/' . Config::get('core::core.admin-prefix'));
}
}
\ No newline at end of file
......@@ -18,7 +18,9 @@ class UsersServiceProvider extends ServiceProvider
* @var array
*/
protected $filters = [
'permissions' => 'PermissionFilter'
'Core' => [
'permissions' => 'PermissionFilter'
]
];
/**
......@@ -52,10 +54,12 @@ class UsersServiceProvider extends ServiceProvider
*/
public function registerFilters(Router $router)
{
foreach ($this->filters as $name => $filter) {
$class = 'Modules\\User\\Http\\Filters\\' . $filter;
foreach ($this->filters as $module => $filters) {
foreach ($filters as $name => $filter) {
$class = "Modules\\{$module}\\Http\\Filters\\{$filter}";
$router->filter($name, $class);
$router->filter($name, $class);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment