Finish subuser controller

This commit is contained in:
Dane Everitt 2017-09-04 18:12:13 -05:00
parent 7222754580
commit dc310ffdea
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
16 changed files with 524 additions and 161 deletions

View file

@ -25,27 +25,9 @@
namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
class AdminAuthenticate
{
/**
* The Guard implementation.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
@ -55,15 +37,15 @@ class AdminAuthenticate
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
if (! $request->user()) {
if ($request->expectsJson() || $request->json()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('auth/login');
}
}
if ($this->auth->user()->root_admin !== 1) {
if (! $request->user()->root_admin) {
return abort(403);
}