2016-08-28 10:05:21 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
2016-12-17 22:45:08 +08:00
|
|
|
class CheckAdministrator
|
2016-08-28 10:05:21 +08:00
|
|
|
{
|
|
|
|
public function handle($request, \Closure $next)
|
|
|
|
{
|
2017-01-08 14:15:55 +08:00
|
|
|
$result = (new CheckAuthenticated)->handle($request, $next, true);
|
2016-08-28 10:05:21 +08:00
|
|
|
|
2017-01-08 14:15:55 +08:00
|
|
|
if ($result instanceof \Illuminate\Http\RedirectResponse) {
|
|
|
|
return $result;
|
2016-08-29 23:08:09 +08:00
|
|
|
}
|
|
|
|
|
2017-01-08 14:15:55 +08:00
|
|
|
if (!$result->isAdmin()) {
|
|
|
|
abort(403, trans('auth.check.admin'));
|
2016-08-28 10:05:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|