allowed login models and update of login controller
This commit is contained in:
@@ -29,30 +29,30 @@ class AuthServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(GateContract $gate)
|
||||
{
|
||||
|
||||
/*
|
||||
$this->registerPolicies($gate);
|
||||
|
||||
$gate->define('isAdmin', function($user) {
|
||||
$permission = false;
|
||||
$perms = UserPermission::where('character_id', auth()->user()->character_id)->get(['permission']);
|
||||
foreach($perms as $perm) {
|
||||
if($perm === 'role.admin') {
|
||||
$permission = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return $permission;
|
||||
return false;
|
||||
});
|
||||
|
||||
$gate->define('isDirector', function($user) {
|
||||
$permission = false;
|
||||
$perms = UserPermission::where('character_id', auth()->user()->character_id)->get(['permission']);
|
||||
foreach($perms as $perm) {
|
||||
if($perm === 'role.director') {
|
||||
$permission = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return $permission;
|
||||
return false;
|
||||
});
|
||||
|
||||
$gate->define('isUser', function($user) {
|
||||
@@ -90,5 +90,6 @@ class AuthServiceProvider extends ServiceProvider
|
||||
|
||||
return $permission;
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
+6
-8
@@ -52,10 +52,6 @@ class User extends Authenticatable
|
||||
return User::where('user_type')->get();
|
||||
}
|
||||
|
||||
public function role() {
|
||||
return $this->hasOne('App\Models\User\UserRole', 'character_id');
|
||||
}
|
||||
|
||||
public function permissions() {
|
||||
return $this->hasMany('App\Models\User\UserPermission', 'character_id');
|
||||
}
|
||||
@@ -70,11 +66,13 @@ class User extends Authenticatable
|
||||
|
||||
public function hasPermission($permission) {
|
||||
$found = UserPermission::where(['character_id' => $this->character_id, 'permission' => $permission])->get(['permission']);
|
||||
if(isset($found[0]->permission) && $found[0]->permission == $permission) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
foreach($found as $foo) {
|
||||
if($foo->permission === $permission) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function tickets() {
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdoownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Moons</a>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropDownMenuLink">
|
||||
@can('isGuest')
|
||||
@if(User::hasPermission('role.guest'))
|
||||
<a class="dropdown-item" href="/moons/display">Display Moons</a>
|
||||
@endcan
|
||||
@can('isUser')
|
||||
@endif
|
||||
@if(User::hasPermission('role.user'))
|
||||
<a class="dropdown-item" href="/moons/display">Display Moons</a>
|
||||
<a class="dropdown-item" href="/moons/display/worth">Moon Worth</a>
|
||||
@endcan
|
||||
@can('isAdmin')
|
||||
@endif
|
||||
@if(User::hasPermission('role.admin'))
|
||||
<a class="dropdown-item" href="/moons/admin/display">Display Moons</a>
|
||||
<a class="dropdown-item" href="/moons/display/worth">Moon Worth</a>
|
||||
<a class="dropdown-item" href="/moons/admin/addmoon">Add Moon</a>
|
||||
<a class="dropdown-item" href="/moons/admin/updatemoon">Update Moon</a>
|
||||
<a class="dropdown-item" href="/moons/admin/journal">Journal</a>
|
||||
@endcan
|
||||
@endif
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
|
||||
Reference in New Issue
Block a user