user permissions
This commit is contained in:
@@ -23,6 +23,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
* These gates will always choose the highest roles
|
||||
* We use gates in some of the graphics, but will work to utilize if statements instead shortly
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -31,8 +32,10 @@ class AuthServiceProvider extends ServiceProvider
|
||||
$this->registerPolicies($gate);
|
||||
|
||||
$gate->define('isAdmin', function($user) {
|
||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
||||
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
if($check[0]->role === 'Admin') {
|
||||
//User has the Admin role
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -40,8 +43,10 @@ class AuthServiceProvider extends ServiceProvider
|
||||
});
|
||||
|
||||
$gate->define('isDirector', function($user) {
|
||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
||||
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
if($check[0]->role === 'Director') {
|
||||
//User has the Director role
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -49,8 +54,10 @@ class AuthServiceProvider extends ServiceProvider
|
||||
});
|
||||
|
||||
$gate->define('isUser', function($user) {
|
||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
||||
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
if($check[0]->role === 'User') {
|
||||
//User has the User role
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -58,8 +65,10 @@ class AuthServiceProvider extends ServiceProvider
|
||||
});
|
||||
|
||||
$gate->define('isGuest', function($user) {
|
||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
||||
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
if($check[0]->role === 'Guest') {
|
||||
//User has the Guest role
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -67,8 +76,10 @@ class AuthServiceProvider extends ServiceProvider
|
||||
});
|
||||
|
||||
$gate->define('isNone', function($user) {
|
||||
//Get the roles the user has from the user_roles table and check against the gate we are creating
|
||||
$check = DB::table('user_roles')->where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
if($check[0]->role === 'None') {
|
||||
//User has no role
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -35,7 +35,8 @@ class RouteServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
//Don't want to map Api Routes as we aren't going to be using an API
|
||||
//$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user