Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
14.29% |
5 / 35 |
| CheckAccessController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
386.73 | |
14.29% |
5 / 35 |
| preventSuperAdminToEditOtherSuperAdmin | |
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 7 |
|||
| preventAdminTOAccessSuperAdmin | |
0.00% |
0 / 1 |
5.58 | |
71.43% |
5 / 7 |
|||
| preventAdminWithoutTokenToAccessOtherWithToken | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 7 |
|||
| preventAdminWithTokenToAccessOtherWithToken | |
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 7 |
|||
| preventSubAdminTOAccessOtherRoles | |
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 7 |
|||
| <?php | |
| namespace App\Http\Controllers\Admin; | |
| use App\User; | |
| use App\Http\Controllers\Controller; | |
| use Illuminate\Support\Facades\Auth; | |
| use Illuminate\Support\Facades\Route; | |
| class CheckAccessController extends Controller | |
| { | |
| public static function preventSuperAdminToEditOtherSuperAdmin($id) | |
| { | |
| if (Auth::check()){ | |
| $superAdmin = Auth::user(); | |
| $edit = User::find($id); | |
| if (($superAdmin->role == 'super_admin' && $edit->role == 'super_admin') && ($edit->id != $superAdmin->id)){ | |
| return false; | |
| } | |
| return true; | |
| } | |
| return true; | |
| } | |
| public static function preventAdminTOAccessSuperAdmin($id) | |
| { | |
| if (Auth::check()){ | |
| $admin = Auth::user(); | |
| $edit = User::find($id); | |
| if (($admin->role == 'admin' && $edit->role == 'super_admin') && ($edit->id != $admin->id)){ | |
| return false; | |
| } | |
| return true; | |
| } | |
| return true; | |
| } | |
| public static function preventAdminWithoutTokenToAccessOtherWithToken($id) | |
| { | |
| if (Auth::check()){ | |
| $user = Auth::user(); | |
| $other = User::find($id); | |
| if ($user->admin_token == null && $other->admin_token){ | |
| return false; | |
| } | |
| return true; | |
| } | |
| return true; | |
| } | |
| public static function preventAdminWithTokenToAccessOtherWithToken($id) | |
| { | |
| if (Auth::check()){ | |
| $user = Auth::user(); | |
| $other = User::find($id); | |
| if (($user->admin_token && $other->admin_token) && ($user->id != $other->id)){ | |
| return false; | |
| } | |
| return true; | |
| } | |
| return true; | |
| } | |
| public static function preventSubAdminTOAccessOtherRoles($id) | |
| { | |
| if (Auth::check()){ | |
| $subAdmin = Auth::user(); | |
| $superAdmin = User::find($id); | |
| if (($subAdmin->role == 'sub_admin' && $superAdmin->role != 'sub_admin') && ($superAdmin->id != $subAdmin->id)){ | |
| return false; | |
| } | |
| return true; | |
| } | |
| return true; | |
| } | |
| } |