| Total Complexity | 7 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class CheckIfAdmin |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Checked that the logged in user is an administrator. |
||
| 11 | * |
||
| 12 | * -------------- |
||
| 13 | * VERY IMPORTANT |
||
| 14 | * -------------- |
||
| 15 | * If you have both regular users and admins inside the same table, |
||
| 16 | * change the contents of this method to check that the logged in user |
||
| 17 | * is an admin, and not a regular user. |
||
| 18 | * |
||
| 19 | * @param [type] $user [description] |
||
|
2 ignored issues
–
show
|
|||
| 20 | * |
||
| 21 | * @return bool [description] |
||
|
1 ignored issue
–
show
|
|||
| 22 | */ |
||
| 23 | private function checkIfUserIsAdmin($user) |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Answer to unauthorized access request. |
||
| 30 | * |
||
| 31 | * @param [type] $request [description] |
||
|
2 ignored issues
–
show
|
|||
| 32 | * |
||
| 33 | * @return [type] [description] |
||
| 34 | */ |
||
| 35 | private function respondToUnauthorizedRequest($request) |
||
|
1 ignored issue
–
show
|
|||
| 36 | { |
||
| 37 | if ($request->ajax() || $request->wantsJson()) { |
||
| 38 | return response(trans('backpack::base.unauthorized'), 401); |
||
| 39 | } else { |
||
| 40 | return redirect()->guest(backpack_url('login')); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Handle an incoming request. |
||
| 46 | * |
||
| 47 | * @param \Illuminate\Http\Request $request |
||
|
1 ignored issue
–
show
|
|||
| 48 | * @param \Closure $next |
||
|
1 ignored issue
–
show
|
|||
| 49 | * |
||
| 50 | * @return mixed |
||
| 51 | */ |
||
| 52 | public function handle($request, Closure $next) |
||
| 63 | } |
||
| 64 | } |
||
| 65 |