Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
50.00% |
3 / 6 |
| Admin_Auth | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
4.12 | |
50.00% |
3 / 6 |
| handle | |
0.00% |
0 / 1 |
4.12 | |
50.00% |
3 / 6 |
|||
| <?php | |
| namespace App\Http\Middleware; | |
| use Closure; | |
| use Illuminate\Support\Facades\Auth; | |
| class Admin_Auth | |
| { | |
| /** | |
| * Handle an incoming request. | |
| * Redirect user to admin login page if he has not the previliage to access the admin panel | |
| * @param \Illuminate\Http\Request $request | |
| * @param \Closure $next | |
| * @return mixed | |
| */ | |
| public function handle($request, Closure $next) | |
| { | |
| if ( ! Auth::check() ) { | |
| return redirect('admin/login'); | |
| } | |
| if ( ! in_array( Auth::user()->role, ['super_admin','admin', 'sub_admin'] )) { | |
| Auth::logout(); | |
| return redirect('admin/login'); | |
| } | |
| return $next($request); | |
| } | |
| } |