-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from ayooby/master
Admin roles feature
- Loading branch information
Showing
21 changed files
with
517 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ | |
return array( | ||
|
||
'controllers' => array( | ||
'Admin' , 'Link' | ||
'Admin' , | ||
'Link' , | ||
'Permission', | ||
'Role' | ||
), | ||
); |
53 changes: 53 additions & 0 deletions
53
src/Serverfireteam/Panel/libs/PermissionCheckMiddleware.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Serverfireteam\Panel\libs; | ||
|
||
use Lang; | ||
use Closure; | ||
use Gate; | ||
|
||
use Serverfireteam\Panel\Admin; | ||
|
||
class PermissionCheckMiddleware | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \Closure $next | ||
* @return mixed | ||
*/ | ||
|
||
protected $app; | ||
public function handle($request, Closure $next) | ||
{ | ||
|
||
$admin= Admin::find((\Auth::guard('panel')->user()->id)); | ||
|
||
$urlSegments = $request->segments(); | ||
|
||
if ($admin->hasRole('super')){ | ||
|
||
return $next($request); | ||
}else{ | ||
if (key_exists(2 , $urlSegments)){ | ||
|
||
$PermissionToCheck = $urlSegments[1].$urlSegments[2]; | ||
|
||
if($admin->hasPermission($PermissionToCheck)){ | ||
|
||
return $next($request); | ||
}else{ | ||
/** | ||
* Show Access denied page to User | ||
*/ | ||
|
||
abort(403); | ||
} | ||
} | ||
return $next($request); | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Serverfireteam\Panel; | ||
|
||
use Serverfireteam\Panel\CrudController; | ||
|
||
class PermissionController extends CrudController { | ||
|
||
public function all($entity) { | ||
|
||
parent::all($entity); | ||
|
||
$this->filter = \DataFilter::source(new Permission()); | ||
$this->filter->add('id', 'ID', 'text'); | ||
$this->filter->add('name', 'Name', 'text'); | ||
$this->filter->submit('search'); | ||
$this->filter->reset('reset'); | ||
$this->filter->build(); | ||
|
||
$this->grid = \DataGrid::source($this->filter); | ||
$this->grid->add('id', 'ID', true)->style("width:100px"); | ||
$this->grid->add('name', 'Url')->style('width:100px'); | ||
$this->grid->add('label', 'Description'); | ||
|
||
$this->addStylesToGrid(); | ||
|
||
return $this->returnView(); | ||
} | ||
|
||
public function edit($entity) { | ||
|
||
parent::edit($entity); | ||
|
||
$this->edit = \DataEdit::source(new Permission()); | ||
|
||
$helpMessage = (\Lang::get('panel::fields.roleHelp')); | ||
|
||
$this->edit->label('Edit Permission'); | ||
$this->edit->link("rapyd-demo/filter", "Articles", "TR")->back(); | ||
$this->edit->add('name', 'Url', 'text')->rule('required'); | ||
$this->edit->add('label', 'Description', 'text')->rule('required'); | ||
|
||
$this->edit->saved(function () use ($entity) { | ||
$this->edit->message('Awesome, Data Saved successfully'); | ||
$this->edit->link('panel/Permission/all', 'Back'); | ||
}); | ||
|
||
$this->addHelperMessage($helpMessage); | ||
|
||
return $this->returnEditView(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.